Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BOOST_THREAD(s) along with --with-boost=/path and --enable-static-boost tries to link with -lboost_thread-mt #72

Open
yapus opened this issue Jun 30, 2015 · 1 comment

Comments

@yapus
Copy link

yapus commented Jun 30, 2015

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

@yapus
Copy link
Author

yapus commented Jun 30, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant