在cMake中使用boost.asio [英] Using boost.asio in cMake

查看:483
本文介绍了在cMake中使用boost.asio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对cMake还是比较陌生,我正在尝试在我的项目中使用boost asio库.

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

我能够让cMake找到其他boost库,例如smart_ptr和lexical_cast,但是当我尝试包含boost/asio.hpp时,却出现了链接器错误:

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'.  

然后我尝试从

find_package(Boost 1.40.0 REQUIRED)

find_package(Boost 1.40.0 REQUIRED COMPONENTS asio)

然后

cMake要求输入Boost_ASIO_LIBRARY_DEBUGBoost_ASIO_LIBRARY_RELEASE.我会以正确的方式这样做吗?如果是这样,我应该在哪里指向cMake查找这些库. (我正在使用cMake 2.6和Boost 1.40.0)

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)

推荐答案

根据ASIO

以下库必须可用才能链接使用Boost.Asio的程序:

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

  • 用于boost :: system :: error_code和boost :: system :: system_error类的Boost.System.
  • Boost.Regex(可选),如果您使用任何带有boost :: regex参数的read_until()或async_read_until()重载.
  • OpenSSL(可选),如果您使用Boost.Asio的SSL支持.

如果您查看链接错误,则会看到它正在寻找Boost.System库.我会尝试将您的CMakLists.txt更改为:

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)

这篇关于在cMake中使用boost.asio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆