问题
I'm creating an application that interfaces with a weather API, and to do so I'm using Poco's HTTPClientSession library, but I'm getting an error at compile time
Undefined symbols for architecture x86_64:
"Poco::Net::HTTPRequest::setHost(std::__1::basic_string<char,std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
Weather::getCSV() in Weather.o
"Poco::Net::HTTPRequest::HTTPRequest()", referenced from:
Weather::getCSV() in Weather.o
"Poco::Net::HTTPRequest::~HTTPRequest()", referenced from:
Weather::getCSV() in Weather.o
"Poco::Net::HTTPResponse::HTTPResponse()", referenced from:
Weather::getCSV() in Weather.o
"Poco::Net::HTTPResponse::~HTTPResponse()", referenced from:
Weather::getCSV() in Weather.o
"Poco::Net::HTTPClientSession::sendRequest(Poco::Net::HTTPRequest&)", referenced from:
Weather::getCSV() in Weather.o
"Poco::Net::HTTPClientSession::HTTPClientSession(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned short)", referenced from:
Weather::getCSV() in Weather.o
"Poco::Net::HTTPClientSession::~HTTPClientSession()", referenced from:
Weather::getCSV() in Weather.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I know from my research that this error is caused by a need for the option -lPocoNet
to be used when calling the compiler, but I use the eclipse IDE, so I'm not sure how to implement the same effect while using eclipse
回答1:
If you are using gcc
, you can go to Project \ Properties
In the properties dialog box, go to C/C++ Build\ Settings\GCC C++ Compiler\ Miscellaneous,
and add -lPocoNet
to "Other flags" as shown below.

来源:https://stackoverflow.com/questions/26371215/how-to-add-compiler-options-in-eclipse-ide