Autoconf问题:“错误:C编译器无法创建可执行文件”

我正在尝试使用GNU autotools构建一个用C语言编写的程序,但我显然设置错误,因为当configure运行时,它会吐出:

 configure: error: C compiler cannot create executables 

如果我查看config.log ,我看到:

 configure:2846: checking for C compiler default output file name configure:2868: gcc conftest.c >&5 conftest.c:3:25: warning: missing terminating " character conftest.c:4: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token configure: failed program was: | /* confdefs.h. */ | #define PACKAGE_NAME "Jackoff" | #define PACKAGE_TARNAME "jackoff | http://github.com/enaeseth/jackoff" | #define PACKAGE_VERSION "0.1" | #define PACKAGE_STRING "Jackoff 0.1" | #define PACKAGE_BUGREPORT "Eric Naeseth " | #define PACKAGE "jackoff | http://github.com/enaeseth/jackoff" | #define VERSION "0.1" | /* end confdefs.h. */ | | int | main () | { | | ; | return 0; | } 

出于某种原因,autoconf正在生成一个无效的测试文件:该行应该只是一个分号? 构建在Ubuntu 9.04和Mac OS X 10.6上以相同的方式失败,所以这绝对是我的错,而不是环境。

麻烦的是PACKAGE_TARNAME (和PACKAGE )中有一个换行符,它在configure.ac文件中设置。 您应该查看它包含的内容 – 修复它,并重新生成configure脚本。

我的一个configure.ac脚本包含(靠近顶部):

 AC_CONFIG_HEADER(config.h) PACKAGE="sqlcmd" VERSION="86.04" AC_MSG_RESULT([Configuring $PACKAGE version $VERSION]) AC_SUBST(PACKAGE) AC_SUBST(VERSION) 

看起来问题出现在“ jackoff http://github.com/enaeseth/jackoff ”中的新行字符中。 检查一下。

PACKAGE_TARNAME看起来不正常。 首先,它有一个嵌入式换行符,这是导致问题的直接原因。

configure.ac的开头有一个额外的AC_INIT参数。 只需删除它。