Reputation: 34589
I'm a newcomer to C++. I am creating a simple GUI application that uses libcurlpp
to visit a webpage, like so:
#include <sstream>
#include <string>
#include <curlpp/cURLpp.hpp>
#include <curlpp/Options.hpp>
using curlpp::Cleanup;
using curlpp::options::Url;
using std::ostringstream;
using std::string;
string MainWindow::getstr(const string &uri)
{
Cleanup cleanup;
ostringstream stream;
stream << Url(uri);
return stream.str();
}
However, when I compile the code, I get about 20 different linker errors saying that all the references to curlpp
are undefined. Sure enough, when I go to the include directories, I see only header files.
If it matters, I'm on Ubuntu 14.04 and I installed libcurlpp
by running an apt-get install libcurlpp-dev
. Is there anything else I have to do to point the compiler to the .cpp
/.o
files and get rid of the undefined references?
Disclaimer: Yes, I did read this, and no, it isn't relevant to my question because it does not talk specifically about dealing with third-party libraries and where the implementation files (.cpp
and .o
) are installed on my system.
Upvotes: 0
Views: 646
Reputation: 1884
You have to add the library to the linker. If you are using Qt Creator, write
LIBS += -lcurlpp
in the .pro
file.
EDIT: You have to add all libraries this way. As the comment says, in the case of cURL++, which is a wrapper for the cURL C library, you'll also need -lcurl
.
Upvotes: 2
Reputation: 1620
If there is no any libcurlpp.a
or libcurlpp.so
, then i recommend you to download again libcurlpp-dev , there are library files inside package.
Upvotes: 3