views:

207

answers:

1

I am trying to use boost's asio library, but I keep getting undefined references. I'm on Dev-Cpp on Windows, which is using the G++ compiler.

I installed boost using the installer from boostpro computing for Boost 1.42.0 [link]. Here is the code of the test program I am trying to make:

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

int main(void){
    std::cout << "Boost test." << std::endl;
}

My boost include headers are under /include and all the libs for boost are compiled and under /lib directly. There seems to be some library that's not being included, but I do not know what is. I've tried including a few likely ones but to no avail.

The kind of linker errors I'm getting are:

[Linker error] undefined reference to `boost::system::get_system_category()'
[Linker error] undefined reference to `boost::system::get_generic_category()' 
[Linker error] undefined reference to `boost::system::get_generic_category()' 
[Linker error] undefined reference to `boost::system::get_generic_category()' 
[Linker error] undefined reference to `boost::system::get_system_category()' 
[Linker error] undefined reference to `WSACleanup@0' 
[Linker error] undefined reference to `WSAStartup@8' 
[Linker error] undefined reference to `boost::system::get_system_category()' 
ld returned 1 exit status 
C:\Dev-Cpp\Projects\Boost Test\Makefile.win [Build Error]  [boostTest.exe] Error 1 

I've been trying to get boost to work for a while and would really appreciate any help on the matter. Thanks in advance.

+3  A: 

I had this problem a few days ago when working with boost::asio. You need compile and link with the boost::system library.

Hassan Syed
How did you do that? I've tried linking all the boost_system and libboost_system libraries I found but I got the same results.
alecRN