未定义模板的隐式实例化'std :: __ 1 :: function <int(double,=“”double,=“”double,=“”double)=“”>'

时间:2017-06-15 12:30:19

标签: c++ c++11 g++ macos-sierra

在我正在进行的项目中,我正在尝试使用curlpp库来生成简单的html GET请求。当我将cpp文件传递给g ++时,我收到以下错误:

/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 }

1 个答案:

答案 0 :(得分:2)

通过向编译器选项添加-std=c++11-std=c++14,通知编译器您希望使用较新的C ++标准的功能。 std::function只是其中之一,在2011年之前不存在。