0

I am trying to compile some code using autotools and am getting stuck when trying to include boost::date-time and boost::regex. I was given an configure.in file that defines that looks for boost::date-time this way

AC_CHECK_LIB(boost_date_time-gcc-mt, main, , [
        AC_CHECK_LIB(boost_date_time-mt, main, , [
                AC_CHECK_LIB(boost_date_time, main, , [
                        AC_MSG_ERROR("Linking against boost::date-time library failed.")])
        ])
])

which appears to be the standard way according to google. But when I run autoreconf:

$ autoreconf -f -s -i
libtoolize: putting auxiliary files in `.'.
libtoolize: linking file `./ltmain.sh'
libtoolize: Consider adding `AC_CONFIG_MACRO_DIR([m4])' to configure.in and
libtoolize: rerunning libtoolize, to keep the correct libtool macros in-tree.
libtoolize: Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am.

and ./configure:

$ CXXFLAGS="-g -w" ./configure --prefix=$INSTALL_PATH
...
checking for main in -lboost_date_time-gcc-mt... no
checking for main in -lboost_date_time-mt... no
checking for main in -lboost_date_time... no
configure: error: "Linking against boost::date-time library failed."

It cannot be found. I know they are there cause I compiled boost 1.53 from scratch. What could be an issue here?

Thanks a lot in advance.

madtowneast
  • 2,350
  • 3
  • 22
  • 31

2 Answers2

0

There are macros at the GNU Autoconf Archive for both boost::date-time and boost::regex. Perhaps they would be more suitable.

It cannot be found. I know they are there cause I compiled boost 1.53 from scratch. What could be an issue here?

You'll have to consult config.log to know that for sure. Since you are looking for the main functions in those libs (which aren't in those libs, but that's another issue), the AC_CHECK_LIB tests generate invalid C++ code, and that may be your problem.

Community
  • 1
  • 1
ldav1s
  • 15,885
  • 2
  • 53
  • 56
0

There's an excellent boost.m4 macro. You can copy it into a top level ./m4 directory.

  • AC_CONFIG_MACRO_DIR([m4]) in configure.ac

  • ACLOCAL_AMFLAGS = -I m4 --install in the top-level Makefile.am

  • invoke aclocal with aclocal -I m4 --install

It's very easy to use the results in configure.ac, e.g., for Boost.Filesystem:

BOOST_REQUIRE([1.53], [ACTION-IF-NOT-FOUND])
AC_SUBST(BOOST_CPPFLAGS)
MY_PROJECT_CPPFLAGS+="$BOOST_CPPFLAGS"

BOOST_FILESYSTEM([mt])
AC_SUBST(BOOST_FILESYSTEM_LIBS)
AC_SUBST(BOOST_FILESYSTEM_LDFLAGS)
MY_PROJECT_LIBFLAGS+="$BOOST_FILESYSTEM_LDFLAGS $BOOST_FILESYSTEM_LIBS"

It will even add dependencies like Boost.System.

Brett Hale
  • 21,653
  • 2
  • 61
  • 90
  • Thanks a lot for the reference. I can use the flags inside the configure.in, but as soon as I try to invoke --with-boost=/path/to/boost it cannot find boost and I am not sure why. Any suggestions? – madtowneast Jun 21 '13 at 20:08
  • @madtowneast - I built boost-1.53 with MacPorts, which places the `boost` directory under: `/opt/local/include` ... that's how it worked for me. The shared libs are under `/opt/local/lib`. – Brett Hale Jun 21 '13 at 20:15