abumq / easyloggingpp

C++ logging library. It is extremely powerful, extendable, light-weight, fast performing, thread and type safe and consists of many built-in features. It provides ability to write logs in your own customized format. It also provide support for logging your classes, third-party libraries, STL and third-party containers etc.
MIT License
3.75k stars 918 forks source link

compile error says `relocation` #832

Closed lanqsh closed 1 year ago

lanqsh commented 1 year ago

After adding easylogging++.cc & easylogging++.h into my project, error occurs as below while easylogging++ is working with a simple demo

OS

Linux lan 5.15.0-46-generic #49-Ubuntu SMP Thu Aug 4 18:03:25 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

error msg

/usr/bin/ld: easylogging++.o: warning: relocation against `_ZN2el4base9elStorageE' in read-only section `.text._ZN2el7Helpers19validateFileRollingEPNS_6LoggerENS_5LevelE[_ZN2el7Helpers19validateFileRollingEPNS_6LoggerENS_5LevelE]'
/usr/bin/ld: easylogging++.o: in function `el::base::DefaultLogDispatchCallback::dispatch(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&)':
/root/easylogging++.cpp:2232: undefined reference to `el::base::elStorage'
/usr/bin/ld: /root/easylogging++.cpp:2244: undefined reference to `el::base::elStorage'
/usr/bin/ld: easylogging++.o: in function `el::base::DefaultLogBuilder::build[abi:cxx11](el::LogMessage const*, bool) const':
/root/easylogging++.cpp:2410: undefined reference to `el::base::elStorage'
/usr/bin/ld: /root/easylogging++.cpp:2462: undefined reference to `el::base::elStorage'
/usr/bin/ld: /root/easylogging++.cpp:2464: undefined reference to `el::base::elStorage'
/usr/bin/ld: easylogging++.o:/root/easylogging++.cpp:2465: more undefined references to `el::base::elStorage' follow
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE