Jake
Jake

Reputation: 7773

libboost-system linker errors when cross-compiling to x86

I'm trying to build a 32-bit application on Ubuntu 11.04 x64. I'm having some issues with the build because of linker errors with libboost. The build statement has -lboost_system in it, but when I try to build I get a bunch of these:

CommunicationModule.cpp:(.text+0x68c1): undefined reference to boost::system::generic_category()

CommunicationModule.cpp:(.text+0x68d7): undefined reference to boost::system::system_category()

Everything I've found on google says I need to link to the boost_system library. One place I found says to try linking to it directly, but when i do locate boost_system the result is empty. When I try doing a sudo apt-get install libboost-system-dev it tells me that it's already installed. I'm kind of at a loss here. The library is installed, but it's not being found by locate?

Can anyone tell me what I need to do to properly link to boost::system? I'm fairly new to linux and the complexities of compilers so any help here would be appreciated.

Update:

Here is the output of dpkg -L libboost-system1.42-dev:

/. 
/usr 
/usr/share 
/usr/share/doc
/usr/share/doc/libboost-system1.42-dev
/usr/share/doc/libboost-system1.42-dev/copyright
/usr/share/doc/libboost-system1.42-dev/NEWS.Debian.gz
/usr/share/doc/libboost-system1.42-dev/README.Debian.gz 
/usr/lib
/usr/lib/libboost_system.a
/usr/lib/libboost_system-mt.so
/usr/lib/libboost_system-mt.a 
/usr/lib/libboost_system.so

Is there a flag I can use to link to one of these directly? I tried using -L /usr/lib/libboost_system.so and -L /usr/lib/libboost_system-mt.so and neither of those fixed the issue. Same with just adding /usr/lib/libboost_system.a and /usr/lib/libboost_system-mt.a to the build statement.

Here is the compilation line:

g++ -m32 -Wl,-O1 -o UTNaoTool [.o files] -L/usr/lib32 -lqglviewer-qt4 -lqwt-qt4 -lboost_system -lboost_thread -lQtXml -lQtOpenGL -lQtGui -lQtNetwork -lQtCore -lGLU -lpthread

Update 2:

I downloaded boost 1.49 and built everything for 32-bit and that seemed to help. A lot of the errors went away, but now I still have these:

CommunicationModule.cpp:(.text+0x68c1): undefined reference to boost::system::get_generic_category()

Note that the function is different. So all of my errors are regarding undefined references to get_system_category() and get_generic_category() now. I tried adding a -lboost_filesystem to the build command but that didn't fix this, and I made sure it was referencing the 32-bit library that I built when I built libboost_system.

Upvotes: 4

Views: 3931

Answers (2)

juanchopanza
juanchopanza

Reputation: 227400

Looking at my own installation, it seems libboost-system-dev does not install the libraries. Using dpkg to tell me what was installed bz libboost-system-dev I get:

$ dpkg -L  libboost-system-dev
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/libboost-system-dev
/usr/share/doc/libboost-system-dev/copyright
/usr/share/doc/libboost-system-dev/changelog.gz

Poking around, I think you need to install libboost-system1.48.1 (or some other version).

sudo apt-get install libboost-system1.XX.Y

You can also search fo rthe libraries using the find command, for example, search under /usr for all files starting with libboost_system:

find /usr -name "libboost_system*"

Edit: Since you are cross-compiling from a 64 bit OS to a 32 bit one, you need 32 bit versions of the boost libraries. I would be tempted to set up a small 32 bit virtual machine to do this, rather than cross-compiling all the dependencies.

Upvotes: 1

MimiEAM
MimiEAM

Reputation: 2630

I had the same problem with boost_serialization here is what i found out after couple of googling..

first this library need to be compiled separately : so after downloading the boost library ,extract it and execute sudo ./bootstrap.sh' then sudo ./b2 --with-system

after this step you should be find a result when executing locate boost_system

then to link it manually I did: both should work

g++ boostexample.cpp -o run /PATH/libboost_serialization.a

g++ boostexample.cpp -o run -L/PATH/ -lboost_serialization

well this is a little work around and I'm still looking for how to link the library properly

I hope this helped :)

Upvotes: 0

Related Questions