CURLpp,分段错误
CURLpp, segmentation fault
Ubuntu 15.04,CLion,LibCurl,curl 版本 - 7.38.00
。当我编译这段代码时:
#include <curlpp/cURLpp.hpp>
#include <curlpp/Easy.hpp>
#include <curlpp/Options.hpp>
#include <string>
#include <sstream>
int main()
{
try
{
std::string url = "http://www.example.com/";
std::stringstream ss;
curlpp::Cleanup cleanup;
curlpp::Easy request;
request.setOpt(new curlpp::options::Url(url));
request.setOpt(new curlpp::options::WriteStream(&ss));
request.perform();
std::string result = ss.str();
std::cout << "Amount of read symbols: " << result.size() << std::endl;
}
catch( cURLpp::RuntimeError &e )
{
std::cerr << e.what() << std::endl;
return 1;
}
catch( cURLpp::LogicError &e )
{
std::cerr << e.what() << std::endl;
return 1;
}
return 0;
}
没有错误或警告。但是,当我是 运行 可执行文件时,出现错误:./a.out: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/lib/x86_64-linux-gnu/libcurlpp.so.0)
Segmentation fault.
问题是什么?
谢谢。
已安装的 curl 列表:apt --installed list | grep 'curl'
curl/vivid-updates,vivid-security,now 7.38.0-3ubuntu2.2 amd64 [installed]
libcurl3/vivid-updates,vivid-security,now 7.38.0-3ubuntu2.2 amd64 [installed]
libcurl3-gnutls/vivid-updates,vivid-security,now 7.38.0-3ubuntu2.2 amd64 [installed]
libcurl4-openssl-dev/vivid-updates,vivid-security,now 7.38.0-3ubuntu2.2 amd64 [installed]
libcurlpp-dev/vivid,now 0.7.3-6 amd64 [installed]
libcurlpp0/vivid,now 0.7.3-6 amd64 [installed]
python-pycurl/vivid,now 7.19.5-3ubuntu1 amd64 [installed,automatic]
python3-pycurl/vivid,now 7.19.5-3ubuntu1 amd64 [installed]
列表 usr/local/lib
libcurl.a libcurl.so libcurl.so.4.4.0 python3.4
libcurl.la libcurl.so.4 python2.7
命令输出:ldd ./a.out
linux-vdso.so.1 => (0x00007ffc2f17b000)
libcurlpp.so.0 => /usr/lib/x86_64-linux-gnu/libcurlpp.so.0 (0x00007fcff7efc000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fcff7bed000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fcff79d6000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fcff760c000)
libcurl.so.4 => /usr/local/lib/libcurl.so.4 (0x00007fcff73b9000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fcff70b0000)
/lib64/ld-linux-x86-64.so.2 (0x00007fcff8156000)
有额外的库 curl-7.45
,我不得不删除并更新其他库。
命令:
$ sudo rm libcurl.so.4.4.0 //(in usr/local/lib)
$ sudo apt-get update
$ sudo apt-get install libcurl4-openssl-dev //(Optionally)
感谢@KnudLarsen
Ubuntu 15.04,CLion,LibCurl,curl 版本 - 7.38.00
。当我编译这段代码时:
#include <curlpp/cURLpp.hpp>
#include <curlpp/Easy.hpp>
#include <curlpp/Options.hpp>
#include <string>
#include <sstream>
int main()
{
try
{
std::string url = "http://www.example.com/";
std::stringstream ss;
curlpp::Cleanup cleanup;
curlpp::Easy request;
request.setOpt(new curlpp::options::Url(url));
request.setOpt(new curlpp::options::WriteStream(&ss));
request.perform();
std::string result = ss.str();
std::cout << "Amount of read symbols: " << result.size() << std::endl;
}
catch( cURLpp::RuntimeError &e )
{
std::cerr << e.what() << std::endl;
return 1;
}
catch( cURLpp::LogicError &e )
{
std::cerr << e.what() << std::endl;
return 1;
}
return 0;
}
没有错误或警告。但是,当我是 运行 可执行文件时,出现错误:./a.out: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/lib/x86_64-linux-gnu/libcurlpp.so.0)
Segmentation fault.
问题是什么?
谢谢。
已安装的 curl 列表:apt --installed list | grep 'curl'
curl/vivid-updates,vivid-security,now 7.38.0-3ubuntu2.2 amd64 [installed]
libcurl3/vivid-updates,vivid-security,now 7.38.0-3ubuntu2.2 amd64 [installed]
libcurl3-gnutls/vivid-updates,vivid-security,now 7.38.0-3ubuntu2.2 amd64 [installed]
libcurl4-openssl-dev/vivid-updates,vivid-security,now 7.38.0-3ubuntu2.2 amd64 [installed]
libcurlpp-dev/vivid,now 0.7.3-6 amd64 [installed]
libcurlpp0/vivid,now 0.7.3-6 amd64 [installed]
python-pycurl/vivid,now 7.19.5-3ubuntu1 amd64 [installed,automatic]
python3-pycurl/vivid,now 7.19.5-3ubuntu1 amd64 [installed]
列表 usr/local/lib
libcurl.a libcurl.so libcurl.so.4.4.0 python3.4
libcurl.la libcurl.so.4 python2.7
命令输出:ldd ./a.out
linux-vdso.so.1 => (0x00007ffc2f17b000)
libcurlpp.so.0 => /usr/lib/x86_64-linux-gnu/libcurlpp.so.0 (0x00007fcff7efc000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fcff7bed000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fcff79d6000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fcff760c000)
libcurl.so.4 => /usr/local/lib/libcurl.so.4 (0x00007fcff73b9000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fcff70b0000)
/lib64/ld-linux-x86-64.so.2 (0x00007fcff8156000)
有额外的库 curl-7.45
,我不得不删除并更新其他库。
命令:
$ sudo rm libcurl.so.4.4.0 //(in usr/local/lib)
$ sudo apt-get update
$ sudo apt-get install libcurl4-openssl-dev //(Optionally)
感谢@KnudLarsen