我对curlpp库有问题。我将解释我遵循的步骤。
步骤1:下载并安装
下载网站:Download
$./configure
$make
$sudo make install
步骤2:我使用了以下代码:
#include <curlpp/cURLpp.hpp>
#include <curlpp/Easy.hpp>
#include <curlpp/Options.hpp>
#include <curlpp/Exception.hpp>
using namespace std;
int main()
{
char *url = (char*) "http://dbpedia.org/sparql";
string queryString = "PREFIX dbp: <http://dbpedia.org/resource/> "
"PREFIX dbp2: <http://dbpedia.org/ontology/> "
"SELECT ?abstract "
"WHERE { "
"dbp:Nikola_Tesla dbp2:abstract ?abstract . "
"FILTER langMatches(lang(?abstract), 'en')"
"}";
try
{
curlpp::Easy request;
string parameters = "query=" + curlpp::escape(queryString);
request.setOpt(new curlpp::options::Url(url));
request.setOpt(new curlpp::options::Verbose(true));
request.setOpt(new curlpp::options::PostFields(parameters));
request.perform();
}
catch (curlpp::RuntimeError & e)
{
std::cout << e.what() << std::endl;
}
catch (curlpp::LogicError & e)
{
std::cout << e.what() << std::endl;
}
return 0;
}//end function main
错误
如图所示添加-lcurlpp后:我得到以下错误:
最佳答案
编译和链接代码时,需要与-lcurlpp
链接。
关于c++ - 在Kubuntu上使用code::blocks未定义对curlpp的引用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29119357/