My set up of autoconf is fairly new:

m4 (GNU M4) 1.4.17 and came with ubuntu
autoconf (GNU Autoconf) 2.69

My configure.ac is fairly simple:

 30 ACX_PTHREAD([ 
 31   AC_DEFINE([HAVE_PTHREAD], [1], [Define if you have POSIX threads libraries and headers])
 32   gtest_LIBS="$PTHREAD_LIBS $LIBS"
 33   gtest_CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
 34   gtest_CXXFLAGS="$CXXFLAGS $PTHREAD_CXXFLAGS"
 35   gtest_CC="$PTHREAD_CC"
 36   gtest_CXX="$PTHREAD_CXX"])

Running autconf gave me the error:

autoreconf -fi
libtoolize: putting auxiliary files in '.'.
libtoolize: copying file './ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: copying file 'm4/libtool.m4'
libtoolize: copying file 'm4/ltoptions.m4'
libtoolize: copying file 'm4/ltsugar.m4'
libtoolize: copying file 'm4/ltversion.m4'
libtoolize: copying file 'm4/lt~obsolete.m4'
configure.ac:31: error: possibly undefined macro: AC_DEFINE
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.

I believe that my ACX_PTHREAD macro is giving me trouble. I looked into the definition of this macro and did not find anything strange. There are suggestions that this is caused by the missing pkg.m4 in other situations. I verified that the latest version pkg-config is installed on my system. The pkg.m4 is present on my system: /usr/share/aclocal. I have been researching a solution for this problem and could not get anywhere.

1

There are 1 answers

1
Kemin Zhou On BEST ANSWER

My problem turned out to be due to the lack of axc_pthread.m4 file. This is how I discovered it:

autoreconf -fi gave the error message. If I run autoreconf -i then the program will run silently without any error messages. The run ./configure will reveal the problem at the line where ACX_PTHREAD(...) is copied verbatim to the configure file. This indicates that the ACX_PTHREAD macro is not defined in my system.

The download link is at: http://ac-archive.sourceforge.net/ac-archive/acx_pthread.html. After some research, there seems to be many sources providing this macro definition. Not sure which one is better. But I am eager to get this problem solved. After coping this file into my projects's m4 directory, my problem got resolved. Hope this may help others. The problem with autoconf is that usually a problem shows a wrong symptom.