2017-12-26 11 views
0

私はUbuntu 16.04でCasablancaと他のすべての依存関係を正しく構築しました。しかし、私がthisサイトのこれらのC++の例に従うと、プログラムはmethods::GETというメンバーを見つけることができませんでした。 methodsのみ表示されますが、その子メンバーはありません。私は何を取りこぼしたか? ありがとうございます。メソッド:: GETがC++ RESTに見つかりません

更新:

は、ここで私が使用したコードです:

#include <http_client.h> 
#include <filestream.h> 
#include <iostream> 
#include <sstream> 

using namespace web::http; 
using namespace web::http::client; 

// Creates an HTTP request and prints the length of the response stream. 
pplx::task<void> HTTPStreamingAsync() 
{ 
    http_client client(L"http://myAddressComesHere"); 

// Make the request and asynchronously process the response. 
return client.request(methods::GET).then([](http_response response) 
{ 
    // Print the status code. 
    std::wostringstream ss; 
    ss << L"Server returned returned status code " << response.status_code() << L'.' << std::endl; 
    std::wcout << ss.str(); 

    // TODO: Perform actions here reading from the response stream. 
    auto bodyStream = response.body(); 

    // In this example, we print the length of the response to the console. 
    ss.str(std::wstring()); 
    ss << L"Content length is " << response.headers().content_length() << L" bytes." << std::endl; 
    std::wcout << ss.str(); 
}); 
} 
+1

[mcve]を入力してください。 – Ron

+0

のメソッドはweb :: httpの一部ですので、与えられた例を使用したい場合は、web :: httpまたはweb :: http :: methods :: GETのメソッド:: GETを置き換えます。それはあなたの問題ですか? – Gibet

+0

私はすでにやりました。私が参照したリンクからわかるように、私は前にその名前空間を批判しました。 –

答えて

0

あなたのプログラムがGET見つからない理由は何も正確なエラーが指定されていない、明確ではありません。
また、使用しているドキュメントが古くなっていますので、gppからcpprestsdkのsourcesのサンプルをお試しください。

とにかく、あなたがUbuntu 16.04を指定したように、あなたはGCCを使っていると思います。ソースからコンパイル

#include <cpprest/http_client.h> 
#include <iostream> 
#include <sstream> 

using namespace utility; 
using namespace web::http; 
using namespace web::http::client; 
using namespace concurrency::streams; 

pplx::task<void> HTTPStreamingAsync() 
{ 
    http_client client("http://www.google.com"); 

return client.request(methods::GET).then([](http_response response) 
{ 
    std::ostringstream ss; 
    ss << "Server returned returned status code " << response.status_code() << '.' << std::endl; 
    std::cout << ss.str(); 

    auto bodyStream = response.body(); 

    ss.str(std::string()); 
    ss << "Content length is " << response.headers().content_length() << " bytes." << std::endl; 
    std::cout << ss.str(); 
}); 
} 

int main() { 
    HTTPStreamingAsync().wait(); 
} 

Cpprestsdk:私は正常にわずか数の変更、完全なサンプルコードを使用して、ソースコードを実行することができています。 gccを使用してコンパイルされたプログラム7.2.1:

g++ -I/usr/local/include/cpprest -o ct main.cpp -lcpprest -lboost_system -lcrypto 
+0

あなたの答えをありがとう。私はまたgccを使ってsouceから作った。しかし、それでも私は 'メソッド'のための 'GET'や他の子メンバーを表示しません。私は 'web :: http'の元の' header'や 'cpp'ファイルを読み込もうとしましたが、まだそれらの子メンバーを含んでいないようです。あなたは何か考えていますか? –

+0

@E_Learner詳細/ http_constants.datで宣言されています。ここで与えられた例はコンパイルされますか? – Gibet

+0

@Gibet残念ながら、いいえ。上記の例のコードでも同じエラーが発生します。 –

関連する問題