c++linuxcurlcurlpp

CURLpp, segmentation fault


Ubuntu 15.04, CLion, LibCurl, curl version - 7.38.00. When i'm compiling this code:

#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;
 }

there are no errors or warnings. But, when i'm running the executable file, incomes the error: ./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. What's the promblem?

Thank you.

List of installed 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]

List of usr/local/lib

libcurl.a   libcurl.so    libcurl.so.4.4.0  python3.4
libcurl.la  libcurl.so.4  python2.7

Output of command :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)

Solution

  • There was extra library curl-7.45, which i had to delete and update other libraries.

    Commands:

    $ sudo rm libcurl.so.4.4.0 //(in usr/local/lib)
    $ sudo apt-get update
    $ sudo apt-get install libcurl4-openssl-dev //(Optionally)
    

    Thanks to @KnudLarsen