Undefined Reference to Symbol when compiling program in C++

Asked

Viewed 79 times

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  

Yet 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 idea how to solve the problem?

1 answer

3


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

Try it this way:

g++ -lcurlpp -lcurl -o http_get httpreq.cpp
  • Thanks! The way it is there did not compile, but I changed the flags of Linker of place, getting g++ -o http_get httpreq.cpp -lcurlpp -lcurl and it worked.

  • Strange, I compile in the order I have in the answer and it works well. Anyway, I’m glad it worked!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.