Boost logo

Boost Users :

Subject: [Boost-users] Can't dynamically load shared lib that is statically linked to boost thread
From: Greg (greg9504_at_[hidden])
Date: 2012-02-01 16:55:28


Hi,

I've run into a problem since adding a dependency on boost_thread. My shared
library no longer loads (via dlopen("libmy.so",RTLD_NOW), I get error:

undefined symbol: _ZTIN5boost6detail16thread_data_baseE

Any ideas on how to resolve this?

Details:
OS - CentOS 5.4, x86_64
Boost version - 1.47.0 built from source
./bootstrap.sh --with-libraries=exception,filesystem,math,thread
--prefix=/usr/local/boost_1_47_0
./b2 install

This worked fine.

Although I built the other boost libraries, I'm only using thread at this time.

Link line for my shared library which uses boost thread:
Building target: libtslib.so
Invoking: GCC C++ Linker
g++ -L"/usr/local/boost_1_47_0/lib"
-L"/opt/xerces-c-3.1.0-x86_64-linux-gcc-3.4/lib"
-L"/home/Greg/workspace/geothreadcpp/Release"
-L"/home/Greg/workspace/geothreadcpp/Debug"
-L"/home/Greg/workspace/geocosmexception/Release"
-L"/home/Greg/workspace/geocosmxmllibbasecpp/Release"
-L"/home/Greg/workspace/xmllib/Release"
-L"/mnt/src/geocosm/matlab/geneticalglib/galibcmplinux_x86_64/distrib" -shared
-o"libtslib.so" ./tslibcpp/src/TsLibCpp.o ./tslib/src/tslibresults.o
./tslib/src/tslibsamplematch.o -lmlgalib -lpthread -lgeothreadcpp
-lgeocosmexception -lxerces-c-3.1 -lgeocosmxmllibbasecpp -lxmllib
Finished building target: libtslib.so

note it is relying on the auto link boost feature which seems to correctly use
the static lib version of boost_thread as "ldd" does not report a dependency on
boost_thread:

ldd libtslib.so
        libmlgalib.so => not found
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00002aae15ec3000)
        libgeothreadcpp.so => not found
        libgeocosmexception.so => not found
        libxerces-c-3.1.so => not found
        libgeocosmxmllibbasecpp.so => not found
        libxmllib.so => not found
        libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00002aae160e0000)
        libm.so.6 => /lib64/libm.so.6 (0x00002aae163e0000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00002aae16664000)
        libc.so.6 => /lib64/libc.so.6 (0x00002aae16872000)
        /lib64/ld-linux-x86-64.so.2 (0x00000036c7a00000)

When my application attempts to load my shared library via dlopen I get the
undefined symbol error.

If I explicitly link to the shared lib version of boost_thread, ldd shows a
dependency (which it should). If I then include a copy of boost_thread .so on
the ld path my shared library loads without problems. However this is what I
wanted to avoid and instead embed lib boost_thread directly into my .so.

Thanks for any insight.
Greg.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net