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.
如果没有任何libcurlpp.a
或libcurlpp.so
,那么我建议您再次下载libcurlpp-dev ,程序包中有库文件。
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
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.