2

I have a problem with curlpp library. I'll explain the steps that I followed.


Step 1: download and installation

download website: Download

$./configure
$make
$sudo make install
  • curlpp header files are located in /usr/local/include/
  • curlpp library files are located in /usr/local/lib/

Step 2: I used the following code:

#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

Errors

  • Undefined reference to curlpp ::Easy:Easy()
  • Undefined reference to curlpp ::escape (const std :: string &)
  • Undefined reference to curlpp ::Easy::setopt (curlpp OptionBase :: *)
  • Undefined reference to curlpp curlpp::Easy::setopt(curlpp OptionBase:: *)
  • etc.

After adding -lcurlpp as the picture shows: I got the following errors: picture 1

g++ -LSQLiteCpp-master/debug -o bin/Debug/EntityLinking obj/Debug/DataLoader.o obj/Debug/Entity.o obj/Debug/Fact.o obj/Debug/FactClass.o obj/Debug/Link.o obj/Debug/main.o obj/Debug/ManageDb.o obj/Debug/SQLiteCpp-master/sqlite3/sqlite3.o obj/Debug/tinyxml/tinystr.o obj/Debug/tinyxml/tinyxml.o obj/Debug/tinyxml/tinyxmlerror.o obj/Debug/tinyxml/tinyxmlparser.o -lpthread -ldl -lcurlpp SQLiteCpp-master/debug/libSQLiteCpp.a /usr/bin/ld: obj/Debug/main.o: référence au symbole non défini «curl_easy_setopt@@CURL_OPENSSL_3» //usr/lib/x86_64-linux-gnu/libcurl.so.4: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status Process terminated with status 1 (0 minute(s), 0 second(s)) 0 error(s), 0 warning(s) (0 minute(s), 0 second(s))

Hani Goc
  • 2,371
  • 5
  • 45
  • 89
  • 1
    have you tried curl-config --libs, or pkg-config --libs curl on the command line? Or have you tried to add -lssl as a linker flag? – Arne Mar 18 '15 at 10:51
  • I added -lcurl witth -lcurlpp to the **other linking options** it actually solved the problem but I don't know why and how to explain it – Hani Goc Mar 18 '15 at 11:14

2 Answers2

1

You need to link with -lcurlpp when compiling & linking your code.

ArnonZ
  • 3,822
  • 4
  • 32
  • 42
  • When I add `-lcurlpp` in other link options. I get the following error: Error adding symbols:DSO missing from command line – Hani Goc Mar 18 '15 at 10:23
  • try putting it in the end of the link command. check [this](http://stackoverflow.com/questions/19901934/strange-linking-error-dso-missing-from-command-line) out. – ArnonZ Mar 18 '15 at 10:24
  • @Amon I added a picture can you check it please i'll check the link that you posted i was just adding it – Hani Goc Mar 18 '15 at 10:34
  • 2
    I actually added just `-lcurl` along side `-lcurlpp` and it worked don't really know why. Thanks for your help – Hani Goc Mar 18 '15 at 10:46
  • make sure you install libcurlpp-dev with this command -> sudo apt install libcurlpp-dev – Galuga Mar 26 '18 at 22:43
0

Using Eclipse, I never got curlpp example01 working. Even after trying to set up the linkers and the includes. But I was able to compile it from a terminal:

g++ -o exe_name exe_name.cpp -L/usr/local/lib -lcurl -lcurlpp -I/usr/local/include

So I would suggest trying the terminal if Eclipse doesn't work for you.

AndyZe
  • 49
  • 4