Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using boost.asio in cMake

I am relatively new to cMake, and I'm trying use the boost asio library in my project.

I was able to get cMake to find other boost libraries such as smart_ptr and lexical_cast, but I get a linker error when I try to include boost/asio.hpp:

LINK : fatal error LNK1104: cannot open file 'libboost_system-vc90-mt-1_40.lib'.  

I then tried to change my CMakeLists.txt from

find_package(Boost 1.40.0 REQUIRED)

to

find_package(Boost 1.40.0 REQUIRED COMPONENTS asio)

cMake then asks for Boost_ASIO_LIBRARY_DEBUG and Boost_ASIO_LIBRARY_RELEASE. Am I going about this the right way, and if so where should I point cMake to find these libraries. (I am using cMake 2.6 and boost 1.40.0)

like image 895
cquillen Avatar asked Jan 16 '10 20:01

cquillen


1 Answers

According to the ASIO documentation:

The following libraries must be available in order to link programs that use Boost.Asio:

  • Boost.System for the boost::system::error_code and boost::system::system_error classes.
  • Boost.Regex (optional) if you use any of the read_until() or async_read_until() overloads that take a boost::regex parameter.
  • OpenSSL (optional) if you use Boost.Asio's SSL support.

If you look at your link error, you will see that it is looking for the Boost.System library. I would try changing your CMakLists.txt to read:

find_package(Boost 1.40.0 REQUIRED system)
like image 130
Trent Avatar answered Sep 23 '22 05:09

Trent