我下载了最新的独立版本Boost's Asio Library。现在我想将纯粹的头文件库整合到一个简单的qt creator C++项目中。但是,如果我尝试运行与asio.hpp的“Hello World”的例子包括我收到以下错误信息(参见下面的完整的错误消息):Asio C++ Library:asio/detail/config.hpp:没有这样的文件或目录
asio/detail/config.hpp: No such file or directory
这是我花了这么远
步骤- Qt Creator中创建了一个新的项目(C++与QMAKE)
- 提取的ASIO库
- 复制ASIO的包括和src文件夹到 “库” 目录在我的项目
CONFIG + = C++ 11
而且我试图添加以下定义在我的主要被用于
#define ASIO_STANDALONE #define ASIO_HAS_STD_ADDRESSOF #define ASIO_HAS_STD_ARRAY #define ASIO_HAS_CSTDINT #define ASIO_HAS_STD_SHARED_PTR #define ASIO_HAS_STD_TYPE_TRAITS #include <iostream> #include "libs/asio/include/asio.hpp" using namespace std; int main() { cout << "Hello World!" << endl; return 0; }
看来qmake并不知道所有的包含。我不是很喜欢cmake,qmake和这个东西。因此,作为一个小白我尝试添加一个新的INCLUDEPATH在.pro文件...
INCLUDEPATH + = ./libs/asio/include
...并得到了一个新的错误:
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'
文件hierarchie:
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在正确的目录中搜索包含文件?
注意:对于源代码的引用抱歉,但我没有设法通过使用源代码“tag”简单地在代码列表中突出显示代码。