我下載了最新的獨立版本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」簡單地在代碼列表中突出顯示代碼。