Vulnerability when using boost could not open file of shared objects

So, I'm trying to compile and run a simple acceleration program

#include <iostream>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>


int main() {
    using namespace boost::asio;
    io_service io;
    deadline_timer t(io, boost::posix_time::seconds(5));
    t.wait();
    std::cout << "Hello World!" << std::endl;

    return 0;
}

The first thing I tried when compiling this program was to do

g++ -I /home/vagrant/boost_1_60_0 main.cpp

what gave me an error

/tmp/cc8Ytqko.o: In function `__static_initialization_and_destruction_0(int, int)':
main.cpp:(.text+0xfc): undefined reference to `boost::system::generic_category()'
main.cpp:(.text+0x108): undefined reference to `boost::system::generic_category()'
main.cpp:(.text+0x114): undefined reference to `boost::system::system_category()'
/tmp/cc8Ytqko.o: In function `boost::system::error_code::error_code()':
main.cpp:(.text._ZN5boost6system10error_codeC2Ev[_ZN5boost6system10error_codeC5Ev]+0x17): undefined reference to `boost::system::system_category()'
/tmp/cc8Ytqko.o: In function `boost::asio::error::get_system_category()':
main.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[_ZN5boost4asio5error19get_system_categoryEv]+0x5): undefined reference to `boost::system::system_category()'
collect2: error: ld returned 1 exit status

So, I did some research, and it seems to me that I needed to create boost_system binaries, so I went to the boost folder, where I was and ran

./bootstrap.sh
./b2 --with-system

Then I compiled again

g++ -I /home/vagrant/boost_1_60_0 main.cpp -L/home/vagrant/boost_1_60_0/stage/lib/ -lboost_system

and this did not give me any error, but when I ran the executable

vagrant@vagrant-ubuntu-trusty-64:/vagrant$ ./a.out
./a.out: error while loading shared libraries: libboost_system.so.1.60.0: cannot open shared object file: No such file or directory

I don’t know what I need to do here

+4
source share
1 answer

liibboost_system.so.1.60.0 , . . LD_LIBRARY_PATH , :

LD_LIBRARY_PATH=/home/vagrant/boost_1_60_0/stage/lib/ ./a.out

bash, , .

+4

All Articles