0

I am trying to use easyloggingpp (https://github.com/easylogging/easyloggingpp) on MacOSx with clang in clion. Just including the easyloggingc++.h file doesn't work, I get the following errors.

It seems like some symbols are missing, but really, there is only a header file for easyloggingpp, so I am not sure what's missing.

Undefined symbols for architecture x86_64:
  "el::base::utils::s_currentHost", referenced from:
      el::base::LogFormat::updateFormatSpec() in main.cpp.o
  "el::base::utils::s_currentUser", referenced from:
      el::base::LogFormat::updateFormatSpec() in main.cpp.o
  "el::base::elStorage", referenced from:
      el::base::Writer::construct(int, char const*, ...) in main.cpp.o
      el::base::MessageBuilder::operator<<(char const*) in main.cpp.o
      el::base::MessageBuilder::operator<<(int) in main.cpp.o
      el::base::Writer::processDispatch() in main.cpp.o
      el::base::Writer::triggerDispatch() in main.cpp.o
      el::base::Writer::initializeLogger(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool) in main.cpp.o
      el::base::LogDispatcher::dispatch() in main.cpp.o
      ...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

MWE:

#include "easylogging++.h"

int main()
{
     LOG(INFO)<<"Message";
}
FooF
  • 4,323
  • 2
  • 31
  • 47
kloop
  • 4,537
  • 13
  • 42
  • 66
  • I think @kloop's problem was not what the error means, but more specifically about how to use easylogging++ library. How does the easylogging++ library give you the necessary definitions, and only once, as for some reason these definitions are not provided inside the library compilaton unit by default (though there is macro definition that gives you this). And the answer is to have magic macro `INITIALIZE_EASYLOGGINGPP` expanded in one of your compilation units, or alternatively compile easylogging++by defining `AUTO_INITIALIZE_EASYLOGGINGPP` from outside when compiling the library. – FooF Aug 05 '17 at 05:12
  • This is not a duplicate question. I mean technically the error message is pretty clear if you have the smallest experience of C/C++, and the claimed duplicate question goes to all kinds of territories explaining all the possible reasons for seeing those kind of errors. But when you want to use somebody else's library and if instead of joyfully succeeding, you witness compiler complaining like this, the problem is not about C++ compilation units... The problem is the library design, and you need to find the correct usage by reading the library documentation or source code. – FooF Aug 05 '17 at 05:25

0 Answers0