加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

boost-asio – 仅限标题的asio独立版

发布时间:2020-12-16 10:44:16 所属栏目:百科 来源:网络整理
导读:提前抱歉提出一个愚蠢的问题 – 我对这一切都很陌生. 所以我从here下载了asio,并尝试#include asio.hpp,但是出现了以下错误; fatal error: boost/config.hpp: No such file or directory 我觉得这很奇怪,因为它假设独立于Boost.我捅了一下,看到我需要定义ASI
提前抱歉提出一个愚蠢的问题 – 我对这一切都很陌生.

所以我从here下载了asio,并尝试#include asio.hpp,但是出现了以下错误;

fatal error: boost/config.hpp: No such file or directory

我觉得这很奇怪,因为它假设独立于Boost.我捅了一下,看到我需要定义ASIO_STANDALONE,我很快就做了,只是遇到了更多的错误,它试图#include来自Boost的其他东西.

是否有一个很重要的列表,列出了所有我要#define告诉它是独立的东西?这将非常有帮助.

解决方法

如Asio website所述:

When using a C++11 compiler,most of Asio may now be used without a dependency on Boost header files or libraries. To use Asio in this way,define ASIO_STANDALONE on your compiler command line or as part of the project options.

因此,即使定义了ASIO_STANDALONE,Asio也会在以下情况下使用Boost:

>使用非C 11编译器.
>使用某些功能时,例如基于Boost.Coroutine库的stackful coroutines.

随着asio-1.10.2,以下程序:

#include <asio.hpp>

int main()
{
  asio::io_service io_service;
}

用gcc 4.8.1编译,使用-DASIO_STANDALONE -std = c 11编译器标志.如果不指定编译器使用c 11,则在尝试包含Boost头文件时编译将失败.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读