-2

When compiling my project that uses boost logging library, I am getting following linker error.

LNK2001 unresolved external symbol "public: static class boost::log::v2s_mt_nt6::sources::severity_logger_mt __cdecl my_logger::construct_logger(void)" (?construct_logger@my_logger@@SA?AV?$severity_logger_mt@W4severity_level@trivial@v2s_mt_nt6@log@boost@@@sources@v2s_mt_nt6@log@boost@@XZ)

I don't know how to read this error message with mangled function names. Can anyone tell me in human readable way what function it cannot find?

whoami
  • 1,689
  • 3
  • 22
  • 45
  • Possible duplicate of https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix – forthe Nov 10 '18 at 04:24
  • 3
    Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – forthe Nov 10 '18 at 04:24
  • i have read the links provided and it does not help me at all as those answers are very generic. Please help me understand this specific scenario. – whoami Nov 10 '18 at 04:26
  • In short: have you been linking against the correct boost library (.lib) files? – forthe Nov 10 '18 at 04:28
  • Your linker is more informative than most. The first line tells you the linker is trying to find a symbol (something with a name, such as a function) needed in order for your program to run, but not finding it. The second line has unmangled information about that missing symbol - it is a function named `my_logger::construct_logger(void)` (the `void` means it is called with no arguments) and has a return type of `boost::log::v2s_mt_nt6::sources::severity_logger_mt`. The `__cdecl` is compiler/system specific, but describes the calling convention of your function. The rest is the mangled name. – Peter Nov 10 '18 at 04:36
  • *"... it does not help me at all as those answers are very generic"* - Right. But the question lacks details like a typical compile command and the link command, so folks can't tell you much more. Why not provide a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) so we get the details? – jww Nov 11 '18 at 01:03

1 Answers1

0

Googling "boost log unresolved external symbol" leads to https://www.boost.org/doc/libs/1_59_0/libs/log/doc/html/log/rationale/namespace_mangling.html (first, highlighted hit) which describes BOOST_LOG_DYN_LINK.

This incidentally also the most frequent answer on SO: https://stackoverflow.com/search?tab=votes&q=%5bboost-log%5d%20linker

However ABI issues can play a role, see e.g. Unresolved external when using boost log

sehe
  • 374,641
  • 47
  • 450
  • 633