Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"bad codegen, pointer diff in boost" error in 32-bit build

Under Mac OS X 10.6 I am building a C++ shared library which links to boost 1.46. I am using the command line tools installed with Xcode 4.0.

The 64-bit build works fine. When building for 32-bit, I get the following error message upon linking:

ld: bad codegen, pointer diff in boost::detail::sp_counted_base::sp_counted_base()to global weak symbol vtable for boost::detail::sp_counted_basefor architecture i386

The only workaround I found is to use g++-4.0 for the 32-bit build. The other compilers I tried (g++-4.2, llvm-g++-4.2 and clang++) all produce the error above.

like image 779
sakra Avatar asked May 22 '11 10:05

sakra


2 Answers

The issue is most likely that you're statically linking together two libraries with different values for the default visibility (-fvisibility). You can either make sure to use the same visibility flags for both boost and your project, or use an explicit export symbol file.

like image 123
servn Avatar answered Oct 05 '22 13:10

servn


you're probably linking a library built with gcc 4.0, which has incompatible ABI with gcc 4.2 and clang. You should rebuild all libraries used with gcc4.2 or clang, using same compiler options as your main application (particular note to the option "C++ standard library type" aka STANDARD_C_PLUS_PLUS_LIBRARY_TYPE which should be set to "static" or "dynamic" consistently in all libraries). Another useful option is "symbols hidden by default" but beware that enabling that would hide nasty bugs that would rise if you pass C++ objects between libraries compiled with different options/compilers.

like image 35
pqnet Avatar answered Oct 05 '22 13:10

pqnet