gpt4 book ai didi

c++ - 在单独的 'build' 目录中使用 autotools build system/Building

转载 作者:行者123 更新时间:2023-11-28 07:57:36 26 4
gpt4 key购买 nike

我正在创建一个软件项目,我想使用 autotools 为我生成 makefile 等脚本,我手动创建了 Makefile.am 和 configure.in 文件,我正在使用 autogen.sh 脚本来自 here .当尝试在单独的“构建”目录中构建项目时出现问题,例如如果我去:

mkdir build
cd build
../configure
make

配置步骤工作正常,但在运行 make 时我得到:

make  all-recursive
Making all in src
/bin/sh: line 0: cd: src: No such file or directory
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

有什么技巧可以让它发挥作用吗?或者我应该放弃并尝试更简单/不同的东西。我计划将其作为一个相当简单的 C++ 项目,我计划唯一依赖于 boost 单元测试框架,并在 Eclipse IDE 中进行大部分开发。

最佳答案

你的 src/Makefile.am 中有一个错误,第 17 行:

swin-adventure_SOURCES = src/main.cc

真正应该阅读:

swin-adventure_SOURCES = main.cc

因为您已经在 src/目录中(除非有 src/src/子文件夹)

还有另一个错误,因为您在 _SOURCES 变量中使用了特殊字符:swin-adventure_SOURCES 具有禁止的 - 字符;尝试将其标准化为 swin_adventure_SOURCES

最后,您尝试多次为 bin_PROGRAMS 赋值(并且每次都是相同的值),请尽量避免这种情况。

类似于:

## Additional flags to pass to aclocal when it is invoked automatically at
## make time. The ${ACLOCAL_FLAGS} variable is picked up from the environment
## to provide a way for the user to supply additional arguments.
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS}

## Define an executable target "swin-adventure", which will be installed into the
## directory named by the predefined variable $(bindir).
bin_PROGRAMS = swin-adventure

## Define the list of source files for the "swin-adventure" target. The file
## extension .cc is recognized by Automake, and causes it to produce rules
## which invoke the C++ compiler to produce an object file (.o) from each
## source file. The ## header files (.h) do not result in object files by
## themselves, but will be included in distribution archives of the project.
swin_adventure_SOURCES = main.cc

关于c++ - 在单独的 'build' 目录中使用 autotools build system/Building,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12348749/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com