Cannot bind boost.system in makefile

Just asked a question about linking Boost libraries in a make file. Thanks to those who helped with this. I ended up with this:

accesstimer: acctime.o bentimer.o g++ -L/usr/local/boost/boost_1_39_0/stage/lib -lboost_system -lboost_filesystem acctime.o bentimer.o -o accesstimer acctime.o: acctime.cpp bentimer.h g++ -I /usr/local/boost/boost_1_39_0 -c acctime.cpp bentimer.o: bentimer.cpp bentimer.h g++ -c bentimer.cpp 

My problem is that boost.filesystem requires boost.system and the above make file cannot find boost.system.

I got the name for boost.filesystem by looking at the / lib dir scene and deleting the lib and trailing section of the file name (libboost_filesystem-gcc41-mt.a). As you can see above, I did the same with libboost_system-gcc41-mt.a and came up with boost_system but cannot be found.

Does anyone know how I would bundle boost.system?

Thanks Uncle zeive, it worked, but as soon as I try to use one of the filesystem keywords (for example, exists), I get the following:

 g++ -I /usr/local/boost/boost_1_39_0 -c acctime.cpp In file included from acctime.cpp:5: bentimer.h:2:19: warning: extra tokens at end of #ifndef directive bentimer.h:11:18: warning: extra tokens at end of #ifdef directive bentimer.h:28:3: warning: no newline at end of file g++ -L/usr/local/boost/boost_1_39_0/stage/lib -lboost_system-gcc41-mt -lboost_filesystem acctime.o bentimer.o -o accesstimer acctime.o: In function `boost::enable_if<boost::filesystem::is_basic_path<boost::filesystem::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem::path_traits> >, bool>::type boost::filesystem::exists<boost::filesystem::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem::path_traits> >(boost::filesystem::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem::path_traits> const&)': acctime.cpp:(.text._ZN5boost10filesystem6existsINS0_10basic_pathISsNS0_11path_traitsEEEEENS_9enable_ifINS0_13is_basic_pathIT_EEbE4typeERKS7_[boost::enable_if<boost::filesystem::is_basic_path<boost::filesystem::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem::path_traits> >, bool>::type boost::filesystem::exists<boost::filesystem::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem::path_traits> >(boost::filesystem::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem::path_traits> const&)]+0x35): undefined reference to `boost::filesystem::detail::status_api(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::system::error_code&)' collect2: ld returned 1 exit status make: *** [accesstimer] Error 1 

Do you know what I'm doing wrong here?

Now I added the -I link to increase the root link to the first link that it builds fine:

 accesstimer: acctime.o bentimer.o g++ -L/usr/local/boost/boost_1_39_0/stage/lib -lboost_system-gcc41-mt -lboost_filesystem-gcc41-mt -I /usr/local/boost/boost_1_39_0 acctime.o bentimer.o -o accesstimer acctime.o: acctime.cpp bentimer.h g++ -I /usr/local/boost/boost_1_39_0 -c acctime.cpp bentimer.o: bentimer.cpp bentimer.h g++ -c bentimer.cpp 

But when I execute, I get:

 ./accesstimer: error while loading shared libraries: libboost_system-gcc41-mt-1_39.so.1.39.0: cannot open shared object file: No such file or directory 

This file is present, but does not collect it.

+4
source share
2 answers

The answer for me, I hope, will help someone else: I had problems with the binding, good people here made me put the necessary things into my file, but I still got:

 ./accesstimer: error while loading shared libraries: libboost_system-gcc41-mt-1_39.so.1.39.0: cannot open shared object file: No such file or directory 

The solution was to simply do:

 ldconfig 

On my Linux machine on which I just installed Boost and created file libraries. I am sure that since ldconfig needs to be run for my system in order to pick up the new libraries that I installed. Now it works.

+1
source

In fact, you should not delete the entire end part, only the extension:

 -lboost_system-gcc41-mt 

The same goes for boost_filesystem:

 -lboost_filesystem-gcc41-mt 
+4
source

All Articles