0

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

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 中进行大部分开发。

4

1 回答 1

1

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

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
于 2012-09-10T14:02:31.383 回答