Vinculando Biblioteca de Boost no Linux

Eu estou tentando construir um projeto usando o Asio do Boost e estou tendo alguns problemas. Inicialmente, tentei construir o projeto sem nenhuma biblioteca adicional, já que tudo está supostamente nos arquivos de cabeçalho.

O programa que estou tentando construir é assim:

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

int main()
{
    boost::asio::io_service io;
    boost::asio::deadline_timer t(io, boost::posix_time::seconds(5));

    t.wait();

    std::cout << "Hello, world!" << std::endl;

    return 0;
}

Pode ser encontradoAqui no site do Boost.

Então, inicialmente eu acabei de ter:

-I /usr/include/boost_1_40_0

Isso resultou nos seguintes erros:

make -k all
Building target: HelloWorld
Invoking: GCC C++ Linker
g++  -o"HelloWorld"  ./main.o  
./main.o: In function `__static_initialization_and_destruction_0':
/usr/include/boost_1_40_0/boost/system/error_code.hpp:205: undefined reference to `boost::system::get_system_category()'
/usr/include/boost_1_40_0/boost/system/error_code.hpp:206: undefined reference to `boost::system::get_generic_category()'
/usr/include/boost_1_40_0/boost/system/error_code.hpp:211: undefined reference to `boost::system::get_generic_category()'
/usr/include/boost_1_40_0/boost/system/error_code.hpp:212: undefined reference to `boost::system::get_generic_category()'
/usr/include/boost_1_40_0/boost/system/error_code.hpp:213: undefined reference to `boost::system::get_system_category()'
./main.o: In function `boost::asio::error::get_system_category()':
/usr/include/boost_1_40_0/boost/asio/error.hpp:218: undefined reference to `boost::system::get_system_category()'
./main.o: In function `error_code':
/usr/include/boost_1_40_0/boost/system/error_code.hpp:312: undefined reference to `boost::system::get_system_category()'
./main.o: In function `posix_tss_ptr':
/usr/include/boost_1_40_0/boost/asio/detail/posix_tss_ptr.hpp:47: undefined reference to `pthread_key_create'
./main.o: In function `~posix_tss_ptr':
/usr/include/boost_1_40_0/boost/asio/detail/posix_tss_ptr.hpp:61: undefined reference to `pthread_key_delete'
./main.o: In function `boost::asio::detail::posix_thread::join()':
/usr/include/boost_1_40_0/boost/asio/detail/posix_thread.hpp:77: undefined reference to `pthread_join'
./main.o: In function `~posix_thread':
/usr/include/boost_1_40_0/boost/asio/detail/posix_thread.hpp:69: undefined reference to `pthread_detach'
collect2: ld returned 1 exit status
make: *** [HelloWorld] Error 1
make: Target `all' not remade because of errors.

Parecia que eu precisava da biblioteca do sistema. Então, segui as instruções do guia Primeiros passos, encontradoAqui, o que me deu um monte de bibliotecas localizadas em/ usr / include / boost_1_40_0 / stage / lib. Entre eles estavalibboost_system.a. Assim, tentei compilar com:

-I /usr/include/boost_1_40_0
-L /usr/include/boost_1_40_0/stage/lib
-l libboost_system

No entanto, eu tenho isso:

make -k all
Building target: HelloWorld
Invoking: GCC C++ Linker
g++ -L/usr/lib -L/usr/include/boost_1_40_0/stage/lib -o"HelloWorld"  ./main.o   -llibboost_system
/usr/bin/ld: cannot find -llibboost_system
collect2: ld returned 1 exit status
make: *** [HelloWorld] Error 1
make: Target `all' not remade because of errors.

Não sei por que, mas não consigo identificar a biblioteca ou qualquer outra que eu tente. O que posso estar fazendo incorretamente? Desde já, obrigado!

questionAnswers(3)

yourAnswerToTheQuestion