我下载了最新的独立版本的Boost的Asio库。现在,我想将头专用库集成到一个简单的qt创建者c++项目中。但是,如果我尝试运行包含asio.hpp的"hello“示例,我将得到以下错误消息(完整错误消息请参见下面):
asio/detail/config.hpp: No such file or directory
这些是我迄今所采取的步骤。
# 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;}
...and得到了一个新错误:
boost/detail/atomic_count.hpp: No such file or directory
这是我的第一个错误的完整错误消息:
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'
档案档案:
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搜索正确目录中的包含文件?
注意:很抱歉引用了源代码,但是我没有通过简单地使用源代码“标记”来获得编号列表中突出显示的代码。
发布于 2015-12-02 14:27:03
也许这会对将来的访客这个问题有所帮助。我设法解决了这个问题。我甚至得到了运行asio的http服务器示例。同时,也从ubuntu切换到debian,从qmake切换到cmake,但我不认为这是最终的原因。以下CMakeLists.txt适用于我:
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选项。我有很多链接错误没有它。另见这里。文件夹结构与以前几乎相同:
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
https://stackoverflow.com/questions/34026873
复制相似问题