Undefined reference to symbol when compiling program in C ++

3

I'm testing the curlPP library and wrote the following program:

#include <iostream>
#include <curlpp/cURLpp.hpp>
#include <curlpp/Easy.hpp>
#include <curlpp/Options.hpp>
#include <sstream>

using namespace std;
using namespace curlpp::options;


int main(int argc, char** argv)
{
   curlpp::Cleanup myCleanup;
   std::cout << curlpp::options::Url("http://wikipedia.org");
   std::ostringstream os;
   os << curlpp::options::Url("http://wikipedia.org");
   return 0;
}

And compiling with the following command:

g++ -o http_get httpreq.cpp -lcurlpp  

However, I get:

/usr/bin/ld: /tmp/ccSQpqLj.o: undefined reference to symbol     'curl_easy_setopt@@CURL_GNUTLS_3'
//usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

Any ideas how to solve the problem?

    
asked by anonymous 12.07.2015 / 03:49

1 answer

3

Including the curlPP library is not enough, you have to compile your program by also using the Curl library.

Try this:

g++ -lcurlpp -lcurl -o http_get httpreq.cpp
    
12.07.2015 / 13:30