2017-06-15 5 views
1

私が取り組んでいるプロジェクトでは、curlppライブラリを使ってシンプルなHTML GETリクエスト。 cppファイルをg ++に渡すと、次のエラーが発生します。未定義テンプレートの暗黙的なインスタンス化 'std :: __ 1 :: function <int(double、double、double、double)>'

/usr/local/include/curlpp/internal/CurlHandle.hpp:185:42: error: implicit instantiation of undefined template 'std::__1::function<int (double, double, double, double)>' 
curlpp::types::ProgressFunctionFunctor mProgressFunctor; 
/usr/local/include/curlpp/internal/CurlHandle.hpp:134:66: error: implicit instantiation of undefined template 'std::__1::function<int (double, double, double, double)>' 
void setProgressFunctor(curlpp::types::ProgressFunctionFunctor functor) 

私はC++にはかなり新しく、どんな助けにも感謝します。私はmacOS Sierraに取り組んでいます。 Homebrewを使ってcurlppをインストールしました(つまり、/ usr/local/Cellarにあります)。


これは私のコードです:

1 #include <string> 
    2 #include <sstream> 
    3 #include <iostream> 
    4 #include <curlpp/cURLpp.hpp> 
    5 #include <curlpp/Easy.hpp> 
    6 #include <curlpp/Options.hpp> 
    7 
    8 using namespace curlpp::options; 
    9 
10 int main(int, char **) 
11 { 
12  try 
13  { 
14   curlpp::Cleanup testCleanup; 
15   curlpp::Easy miRequest; 
16   miRequest.setOpt<Url>("http://www.wikipedia.org"); 
17   miRequest.perform(); 
18  } 
19  catch(curlpp::RuntimeError & e) 
20  { 
21   std::cout << e.what() << std::endl; 
22  } 
23  catch(curlpp::LogicError & e) 
24  { 
25   std::cout << e.what() << std::endl; 
26  } 
27  
28  return 0; 
29 } 
+0

コードは何ですか?試したものをコピーして貼り付けることはできますか? – petersohn

+0

@petersohn done –

+0

私は試してみましたが、このエラーはありません(Ubuntu 16.04、gcc)。 – petersohn

答えて

1

はちょうどあなたがオプションをコンパイラに-std=c++11または-std=c++14のいずれかを追加することによって、新しいC++標準の機能を使用したいコンパイラに知らせます。 std::functionは、2011年より前に存在しなかったものの1つに過ぎません。

+0

ありがとう、私は 'clang ++ -std = C++ 11 -stdlib = libC++ -I/usr/local/Cellar'でコンパイルしましたが、それでもうまくいきませんでした。 –

+0

エラーメッセージは依然として同じですか? –

関連する問題