Binding boost :: thread

I am trying to learn something with extended libraries, but I am having a problem when I try to compile something that includes boost :: threads. I get a binding error message, this message is:

/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lboost-thread 

But this is strange, because it only happens when I compile with a regular user using root, I can compile without problems.

Thanks in advance.

+4
source share
3 answers

check the lib name in the installation upgrade path (default: / usr / lib /), if it is libboost_thread.so, add -lboost_thread. Remember to specify the path to format the directory with -L / usr / lib / boost. If it works only with root privileges, check your privilege in this directory:

 ls -la /usr/lib/ | grep boost 

you should see your username and rw_r_r_ (make sure you have read permission).

If you have this permission in the directory and in boost lib, you can link to gcc:

 g++ obj.o obj2.o -L/usr/lib -lboost_thread 

if you do not have files or you do not have read permissions, log in with administrator rights and add them

 chown -R /usr/lib <your login> chmod +r /usr/lib/lib*.so 
+1
source

Enable

 #include <boost/thread/thread.hpp> 

Other linker flags

 -lboost_system -lboost_thread-mt 
+6
source

Add / path / to / boost to your makefile library Include the path and your error will disappear.

Another option is to include it in your LIBPATH variable

0
source

Source: https://habr.com/ru/post/1399852/


All Articles