I want to add curlpp to my C++ project. Currently, I have a main.cpp file which looks like this:
#include <iostream>
#include <curlpp/cURLpp.hpp>
#include <curlpp/Easy.hpp>
#include <curlpp/Options.hpp>
int main() {
return 0;
}
I compile using: "g++ -std=c++14 -I/usr/nguyenthesang/Desktop/myprogram/curlpp-0.8.1/include main.cpp" and it successfully compiles.
Then I add the implementation in the main function (the below is copied from curlpp's repo):
#include <curlpp/cURLpp.hpp>
#include <curlpp/Easy.hpp>
#include <curlpp/Options.hpp>
using namespace curlpp::options;
int main(int, char **)
{
try
{
// That's all that is needed to do cleanup of used resources (RAII
style).
curlpp::Cleanup myCleanup;
// Our request to be sent.
curlpp::Easy myRequest;
// Set the URL.
myRequest.setOpt<Url>("http://example.com");
// Send request and get a result.
// By default the result goes to standard output.
myRequest.perform();
}
catch(curlpp::RuntimeError & e)
{
std::cout << e.what() << std::endl;
}
catch(curlpp::LogicError & e)
{
std::cout << e.what() << std::endl;
}
return 0;
}
When I compile by using "g++ -std=c++14 -I/usr/nguyenthesang/Desktop/myprogram/curlpp-0.8.1/include main.cpp" , there are compilation errors, which say that "ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)".
The errors may come from the fact that I have only linked the header files to the program but not the library itself. I google around to find the way to link the library (for example using -L options) but it did not work. I need help with this problem.
I also want to ask that is there a general way for adding every library into C++ project, like Cocoapods in iOS?
I appreciate your help.