I have a .cpp file: htonstest.cpp . I use g++ to compile it:
$ g++ -o test htonstest.cpp
It works, and the ./test program works too.
But, when I use automake to compile it, it has a compilation error:
htonstest.cpp: In function 'int main()': htonstest.cpp:6: error๏ผexpected id-expression before '(' token.
My OS is CentOS, gcc version is 4.1.2 20080704, autoconf version is 2.59, automake version is 1.9.6.
Playback:
$ aclocal $ autoheader $ autoconf $ automake -a $ ./configure $ make
ntohstest.cpp:
#include <netinet/in.h>
configure.ac:
AC_PREREQ(2.59) AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS) AC_CONFIG_SRCDIR([htonstest.cpp]) AC_CONFIG_HEADER([config.h]) AM_INIT_AUTOMAKE([foreign]) # Checks for programs. AC_PROG_CXX # Checks for libraries. # Checks for header files. # AC_CHECK_HEADERS([netinet/in.h]) # Checks for typedefs, structures, and compiler characteristics. # Checks for library functions. AC_CONFIG_FILES(Makefile) AC_OUTPUT
Makefile.am:
bin_PROGRAMS=main main_SOURCES=htonstest.cpp
source share