首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Asio C++库:asio/C++/config.hpp:没有这样的文件或目录

Asio C++库:asio/C++/config.hpp:没有这样的文件或目录
EN

Stack Overflow用户
提问于 2015-12-01 17:52:54
回答 1查看 3.5K关注 0票数 1

我下载了最新的独立版本的Boost的Asio库。现在,我想将头专用库集成到一个简单的qt创建者c++项目中。但是,如果我尝试运行包含asio.hpp的"hello“示例,我将得到以下错误消息(完整错误消息请参见下面):

代码语言:javascript
运行
复制
asio/detail/config.hpp: No such file or directory

这些是我迄今所采取的步骤。

  1. 在qt创建者中创建一个新项目(带有qmake的c++)
  2. 提取asio库
  3. 将asio的include和src文件夹复制到项目中的"libs“目录中。
  4. 在.pro文件中指定c++11应由 配置+= c++11
  5. 此外,我还试图在我的主体中添加以下定义:

# ASIO_STANDALONE #定义ASIO_HAS_STD_ADDRESSOF #定义ASIO_HAS_STD_ARRAY #定义ASIO_HAS_CSTDINT #定义ASIO_HAS_STD_TYPE_TRAITS #include #include "libs/asio/include/asio.hpp“使用命名空间std;int main() { cout << "Hello!”<< endl;返回0;}

  1. 似乎qmake并不知道所有的内容。我对cmake,qmake和这类东西不太熟悉。因此,作为一个新手,我试图在.pro文件中添加一个新的INCLUDEPATH . INCLUDEPATH += ./libs/asio/include

...and得到了一个新错误:

代码语言:javascript
运行
复制
boost/detail/atomic_count.hpp: No such file or directory

这是我的第一个错误的完整错误消息:

代码语言:javascript
运行
复制
make: Entering directory `/home/ubuntu/asiotest-build-desktop-Qt_4_8_1_in_PATH__System__Release'
/usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ -o Makefile ../asiotest/asiotest.pro
make: Leaving directory `/home/ubuntu/asiotest-build-desktop-Qt_4_8_1_in_PATH__System__Release'
make: Entering directory `/home/ubuntu/asiotest-build-desktop-Qt_4_8_1_in_PATH__System__Release'
g++ -c -pipe -O2 -Wall -W -DQT_WEBKIT -I/usr/share/qt4/mkspecs/linux-g++ -I../asiotest -I../asiotest -I. -o main.o ../asiotest/main.cpp
In file included from ../asiotest/libs/asio/include/asio.hpp:18:0,
                 from ../asiotest/main.cpp:9:
../asiotest/libs/asio/include/asio/async_result.hpp:18:34: fatal error: asio/detail/config.hpp: No such file or directory
compilation terminated.
make: Leaving directory `/home/ubuntu/asiotest-build-desktop-Qt_4_8_1_in_PATH__System__Release'
make: *** [main.o] Error 1
17:55:01: The process "/usr/bin/make" exited with code 2.
Error while building project asiotest (target: Desktop)
When executing build step 'Make'

档案档案:

代码语言:javascript
运行
复制
asiotest (project folder)
-- asiotest.pro
-- sources (folder)
---- main.cpp
-- libs (folder)
---- asio (folder)
------- include(folder)
---------- asio.hpp 
---------- asio (folder)
------------- detail (folder)
------------- more folders
------- src
---------- asio.cpp
---------- asio_ssl.cpp

如何教qt搜索正确目录中的包含文件?

注意:很抱歉引用了源代码,但是我没有通过简单地使用源代码“标记”来获得编号列表中突出显示的代码。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-12-02 14:27:03

也许这会对将来的访客这个问题有所帮助。我设法解决了这个问题。我甚至得到了运行asio的http服务器示例。同时,也从ubuntu切换到debian,从qmake切换到cmake,但我不认为这是最终的原因。以下CMakeLists.txt适用于我:

代码语言:javascript
运行
复制
project(asiotest)
cmake_minimum_required(VERSION 2.8)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -DASIO_STANDALONE -pthread")
aux_source_directory(. SRC_LIST)
include_directories(asio/include)
add_executable(${PROJECT_NAME} ${SRC_LIST})

注意到-pthread选项。我有很多链接错误没有它。另见这里。文件夹结构与以前几乎相同:

代码语言:javascript
运行
复制
asiotest (project folder)
-- [..source files of http server example..]
-- libs (folder)
---- asio (folder)
------- include(folder)
---------- asio.hpp 
---------- asio (folder)
------------- detail (folder)
------------- more folders
------- src
---------- asio.cpp
---------- asio_ssl.cpp
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34026873

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档