Pergunta

I don't have experience with C++, and only need to make a small adjustment to a C++ application to do a HTTP request to authenticate a user.

Curlpp is an option, but when including the libraries I get an error on building:

Undefined symbols for architecture x86_64:
  "curlpp::OptionBase::OptionBase(CURLoption)", referenced from:
      app_idomsconnector::RTMPAppProtocolHandler::GetAuthPassword(std::string) in libidomsconnector.a(rtmpappprotocolhandler.cpp.o)
      curlpp::OptionTrait<std::string, (CURLoption)10002>::clone() const in libidomsconnector.a(rtmpappprotocolhandler.cpp.o)

As I understand I need to add/link the library in the CMAKELists.txt file. Can anybody tell me what exactly I need to add? (running OSX 10.8) As I mentioned, I have no experience with C++, as I use Java most of the time.

Foi útil?

Solução

As I understand I need to add/link the library in the CMAKELists.txt file.

It is exactly what you have to do :)

In C++, you have two kinds of files to use when you include a library to your project:

  • header files, where the names of symbols are declared (like a list of words)
  • object files, where the code stands (like a dictionary where the words are actually defined)

(this is a little bit simplified but it is not important here)

The error message tells you that you do not provide the object files to the compiler, so it does not know what some words (classes and functions) you use in your project mean.

If you are building an executable named MyExecutable, you must have a line like

add_executable(MyExecutable ...)

in your CMakeLists.txt.

AFTER this line, try to add

target_link_libraries(MyExecutable curlpp)

I you already have a target_link_libraries() line for the MyExecutable target, just add curlpp to the others libraries.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top