我正在嘗試使用Boost的cpp-netlib編寫一個超級小程序來解析示例C++文件中的HTTP URL。如何在我的C++代碼中包含boost項目
的代碼是微不足道的:
#include <boost/network/uri>
#include <iostream>
using namespace boost::network;
int main() {
uri::uri instance("http://www.example.com");
std::cout << "scheme: " << instance.scheme() << std::endl
<< "host: " << instance.host() << std::endl;
return 0;
}
我的測試代碼是在同一目錄下,升壓源。要編譯我簡單地做:
g++ -Icpp-netlib-0.12.0-final -o test test.cpp
它沒有找到包括與-I
雖然過去了,我得到一個致命的錯誤。
fatal error: 'boost/network/uri' file not found
#include <boost/network/uri>
^
1 error generated.
什麼是正確的方法來做到這一點,開始使用他們的庫編寫示例代碼?
我不知道增強多少,但你確定你應該使用boost/network/uri而不是'boost/network/uri.hpp'嗎? – MikeCAT
這給了我一個新的錯誤。致命錯誤:'#include'我在'boost/network/uri /'中看到了'config.hpp',但是在目錄中沒有看到'boost/config.hpp'。 –
randombits
我認爲你的提升安裝被破壞了。也許你沒有安裝開發包? – drescherjm