boost.m4
boost.m4 copied to clipboard
BOOST_THREAD(s) along with --with-boost=/path and --enable-static-boost tries to link with -lboost_thread-mt
I'm trying to link with static boost build and having a problem:
configure.ac
BOOST_REQUIRE([1.52.0]) BOOST_SYSTEM([s]) BOOST_THREADS([s]) BOOST_FOREACH BOOST_PROGRAM_OPTIONS([s]) BOOST_ASIO([s]) BOOST_BIND
and run configure with
./configure --with-boost=/home/user/boost_1_58_0 --enable-static-boost
but linker fails generating the following error:
/bin/sh ../libtool --tag=CXX --mode=link g++ -std=c++0x -D LINUX -Wall -Wno-write-strings -I/home/user/boost_1_58_0 -g -O2 -static -L/home/user/boost_1_58_0/stage/lib -Wl,-R,/home/user/boost_1_58_0/stage/lib -L/home/user/boost_1_58_0/stage/lib -Wl,-R,/home/user/boost_1_58_0/stage/lib -L/home/user/boost_1_58_0/stage/lib -Wl,-R,/home/user/boost_1_58_0/stage/lib -o test1 /home/user/boost_1_58_0/stage/lib/libboost_system.a /home/user/boost_1_58_0/stage/lib/libboost_program_options.a -lboost_thread-mt /home/user/boost_1_58_0/stage/lib/libboost_system.a -lrt libtool: link: g++ -std=c++0x -D LINUX -Wall -Wno-write-strings -I/home/user/boost_1_58_0 -g -O2 -Wl,-R -Wl,/home/user/boost_1_58_0/stage/lib -Wl,-R -Wl,/home/user/boost_1_58_0/stage/lib -Wl,-R -Wl,/home/user/boost_1_58_0/stage/lib -o test1 -L/home/user/boost_1_58_0/stage/lib /home/user/boost_1_58_0/stage/lib/libboost_program_options.a -lboost_thread-mt /home/user/boost_1_58_0/stage/lib/libboost_system.a -lrt test1: In function `boost::thread::start_thread()': /home/user/boost_1_58_0/boost/thread/detail/thread.hpp:179: undefined reference to `boost::thread::start_thread_noexcept()' collect2: ld returned 1 exit status
Somehow -lboost_thread-mt linker flag is being used instead of static link with /home/user/boost_1_58_0/stage/lib/libboost_thread.a.
The host is CentOS 6.5 x64 2.6.32, i have also system Boost installed in /usr/local/lib
This patch helped me
--- a/m4/boost.m4 +++ b/m4/boost.m4 @@ -438,16 +438,10 @@ for boost_rtopt_ in $boost_rtopt '' -d; do # If with_boost is empty, we'll search in /lib first, which is not quite # right so instead we'll try to a location based on where the headers are. boost_tmp_lib=$with_boost - boost_tmp_lib_locs=() - if test x"$with_boost" != x; then - boost_tmp_lib_locs=("$boost_tmp_lib/stage/lib" "$boost_tmp_lib/lib") - else - test x"$with_boost" = x && boost_tmp_lib=${boost_cv_inc_path%/include} - boost_tmp_lib_locs=("$boost_tmp_lib/stage/lib" "$boost_tmp_lib/lib" '' \ + test x"$with_boost" = x && boost_tmp_lib=${boost_cv_inc_path%/include} + for boost_ldpath in "$boost_tmp_lib/stage/lib" "$boost_tmp_lib/lib" '' \ /opt/local/lib* /usr/local/lib* /opt/lib* /usr/lib* \ - "$with_boost" C:/Boost/lib /lib*) - fi - for boost_ldpath in "${boost_tmp_lib_locs[[@]]}" + "$with_boost" C:/Boost/lib /lib* do # Don't waste time with directories that don't exist. if test x"$boost_ldpath" != x && test ! -e "$boost_ldpath"; then