【发布时间】:2018-04-14 01:46:53
【问题描述】:
我正处于将 Autotools 支持添加到 C++ 库的早期阶段。此时我正在使用以下配置运行autoreconf。
$ cat Makefile.am
AUTOMAKE_OPTIONS = foreign
bin_PROGRAMS=cryptest
$ cat configure.ac
AC_INIT(Crypto++, 6.0, http://www.cryptopp.com/wiki/Bug_Report)
AM_INIT_AUTOMAKE
AC_PROG_CXX
AC_CONFIG_FILES([Makefile])
它正在生产:
$ autoreconf --install --force
/usr/share/automake-1.15/am/depend2.am: error: am__fastdepCC does not appear in AM_CONDITIONAL
/usr/share/automake-1.15/am/depend2.am: The usual way to define 'am__fastdepCC' is to add 'AC_PROG_CC'
/usr/share/automake-1.15/am/depend2.am: to 'configure.ac' and run 'aclocal' and 'autoconf' again
Makefile.am: error: C source seen but 'CC' is undefined
Makefile.am: The usual way to define 'CC' is to add 'AC_PROG_CC'
Makefile.am: to 'configure.ac' and run 'autoconf' again.
autoreconf: automake failed with exit status: 1
我正在尝试先解决 error: C source seen but 'CC' is undefined 问题。
基于邮件列表阅读的传统智慧是添加AC_PROG_CC 来解决此问题。我真的不想解决 C++ 标志将导致 C 编译器的问题,尤其是在像 IBM 的 xlc 和 Sun 的 cc 这样的编译器上。考虑到 GNU 完全是关于用户选择,这似乎也是错误的。
我如何告诉 Autotools 这个项目是一个 C++ 项目,它不应该用 C 或 C 编译器做任何事情?
这是它导致的一些问题。
$ egrep 'CC|CFLAGS' Makefile
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
...
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(AM_CFLAGS) $(CFLAGS)
...
CCLD = $(CC)
...
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$ autoreconf --version
autoreconf (GNU Autoconf) 2.69
$ autoconf --version
autoconf (GNU Autoconf) 2.69
$ automake --version
automake (GNU automake) 1.15
【问题讨论】:
-
也许弄清楚为什么会出现错误消息。有关示例,请参见 lists.gnu.org/archive/html/automake/2003-01/msg00053.html。
-
这是一个类似的问题,反过来:gnu-automake.7480.n7.nabble.com/…
-
谢谢奥拉夫。
ls *.c导致ls: cannot access '*.c': No such file or directory;和ls -1 *.cpp | wc -l导致155。 (对我来说)为什么 Autotools 想要一个 C 编译器来做任何事情都是一个谜。 -
他们的 C++ 宏可能仍在搜索 cfront 类型的编译器,如果不搜索 C 编译器会出现问题。