Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

/usr/bin/ld: cannot find -lboost_system-mt

Tags:

c++

boost

I recently upgraded from boost 1.40 to 1.45 by removing the previous boost directory completely, downloading the 1.45 sources and rebuilding the libraries I wanted. I then installed the libs using bjam install.

Nothing else has changed on my machine, yet, now when I am building my C++ program, I get the following link error:

/usr/bin/ld: cannot find -lboost_system-mt

I searched and the file really does not exist. It seems that the mt libraries are no longer part of the library - or am I missing something?

How may I resolve this?

like image 211
skyeagle Avatar asked Jan 04 '11 17:01

skyeagle


People also ask

How do you resolve usr bin Ld Cannot find?

To resolve this problem, you should either provide the library file ( lib{nameOfTheLibrary}. so ) in those search paths or use -L command option. -L{path} tells the g++ (actually ld ) to find library files in path {path} in addition to default paths.

What is Ldflags in Makefile?

LDFLAGS: Extra flags to give to compilers when they are supposed to invoke the linker, 'ld', such as -L. Libraries (-lfoo) should be added to the LDLIBS variable instead. LDLIBS: Library flags or names given to compilers when they are supposed to invoke the linker, 'ld'.


7 Answers

Well, I solved this error on ubuntu 12.04 (x86_64) by the good old scattergun approach

Installing openvrml with the error "cannot find -lboost_filesystem-mt" after make.

libboost-all-dev. installs 54 different packages. One of 'em must've done the trick, runs fine.

like image 182
Kilgore Trout Avatar answered Sep 23 '22 04:09

Kilgore Trout


This version probably doesn't bring multi-threading enabled by default.

Try passing -lboost_system instead of -lboost_system-mt

Edit:

Also it's good to check if the new libs are really inside /usr/local/lib. You should look for /usr/local/lib/libboost_system.so since you did not requested the libs to be built with multi-threading. If the file is there, then your $PATH (environment variable) could be missing /usr/local/lib, and you should update the compilation command so the compiler knows where to find them:

-L/usr/local/lib -lboost_system-mt

like image 45
karlphillip Avatar answered Sep 21 '22 04:09

karlphillip


I had a strange encounter with this, too. My solution was a bid odd - but since it worked for me and I didn't read about it anywhere else, here it is. In my case lboost_python3 was missing.

Hence, i loaded all 54 packages like @Kilgore Trout suggested:

sudo apt-get install libboost-all-dev

Unfortunately, when i looked into the /usr/lib - folder only certain packages were available there. However, when I searched /usr/lib I got more results - the missing files were all in the /usr/lib/arm-linux-gnueabihf - folder.

I simply copy-pasted all libboost-related files into the /usr/lib-folder et voilà - the next time I tried to build anything with the lboost_python3.so , everything worked.

It seems some paths got mixed up or something like this. Hope this helps you or somebody else.

like image 34
Markus Avatar answered Sep 21 '22 04:09

Markus


I have saucy:

$ dpkg -S /usr/lib/libboost_system-mt.so
libboost-system1.49-dev: /usr/lib/libboost_system-mt.so

thus, you can do:

sudo apt-get install libboost-system1.49-dev
like image 26
Frederick Ollinger Avatar answered Sep 22 '22 04:09

Frederick Ollinger


Are your sure the /usr/lib/libboost_system-mt.so sym-link point to the right file:

$ realpath /usr/lib/libboost_system-mt.so

Otherwise you have to install the project or use yours distribution package management. For Debian/Ubuntu it would be apt-get install libboost-system1.45-dev -- but this package does not exists while writing this.

like image 23
Raphael Bossek Avatar answered Sep 24 '22 04:09

Raphael Bossek


Fixed this thanks to @KilgoreTrout's and @user3191035, so here's my notes: I'm on Ubuntu Natty 11.04; my usual state was:

$ dpkg -S libboost_filesystem
libboost-filesystem1.42.0: /usr/lib/libboost_filesystem.so.1.42.0

Then I installed:

sudo apt-get install libboost-all-dev # ton of packages

... and after that, I get this:

$ dpkg -S libboost_filesystem
libboost-filesystem1.42-dev: /usr/lib/libboost_filesystem-mt.a
libboost-filesystem1.42.0: /usr/lib/libboost_filesystem.so.1.42.0
libboost-filesystem1.42-dev: /usr/lib/libboost_filesystem.so
libboost-filesystem1.42-dev: /usr/lib/libboost_filesystem-mt.so
libboost-filesystem1.42-dev: /usr/lib/libboost_filesystem.a

So, that is where the libboost_filesystem-mt.so is in this OS...

like image 42
sdaau Avatar answered Sep 22 '22 04:09

sdaau


change libboost_thread-mt to libboost_thread, first find the address of libboost_thread.so and libboost_thread.a then make softlinks to these files in the same address, so it should be

ln -s /...libboostSourceFiles.../libboost_thread.so /..RequestTOmtFiles.../libboost_thread-mt.so

it works for other libboost -mt files too, like serialization , iostreams, programoptions

like image 39
ImanV Avatar answered Sep 22 '22 04:09

ImanV