1

what does this link error mean ? and how to fix it

error LNK2038: “boost_log_abi” “v2s_mt_nt6” doesn't match  “v2_mt_nt6"

i have tried

  ADD_DEFINITIONS(-DBOOST_ALL_DYN_LINK)
  ADD_DEFINITIONS(-DBOOST_LOG_DYN_LINK)
  ADD_DEFINITIONS(-DBOOST_USE_WINAPI_VERSION=0x601)
周洪宇
  • 13
  • 1
  • 5
  • i havent defined BOOST_LOG_DOXYGEN_PASS when building boost with b2, why it is v2s_mt_nt6 not v2_mt_nt6 – 周洪宇 May 09 '18 at 16:07
  • Could you share a little more context on how your build is set up (what files you link with, or the build command that actually fails)? I suspect you link against a statically built version of Boost, but I need a little more data to back that up – hlt May 09 '18 at 18:00
  • i downloaded a pre-built version of boost, and now its work, i encountered some error when building from the boost source code to generate dynamic library. thanks a lot. – 周洪宇 May 10 '18 at 01:05
  • so the `s` in `v2s_mt_nt6` means static ? – 周洪宇 May 10 '18 at 01:07
  • Yes. It's possible that your build of boost actually ended up generating static libraries - with many of them, you don't notice the differences, but Boost.Log causes trouble. I'll post this as an answer so other people can find it when they search for it. – hlt May 10 '18 at 01:14
  • add_definitions(-D_WIN32_WINNT=0x0601) This worked for me – Neelabh Mam Aug 29 '22 at 08:04

1 Answers1

3

Your Boost.Log library seems to have been built with different flags than your main program.

From config.hpp, we can see what these ABI names mean:

  • v2s_mt_nt6 is statically linked, with multithreading support, on Windows Vista or higher (version 6)

  • v2_mt_nt6 is dynamically linked, with multithreading support, on Windows Vista or higher (version 6)

The BOOST_LOG_DLL macro decides which of the two paths to use. It is defined if any of BOOST_LOG_DYN_LINK or BOOST_ALL_DYN_LINK are defined.

If you statically link against Boost.Log (via a .lib files or similar), you must not define either of these two macros.1

This means that you can either remove the extra preprocessor definitions (because you are trying to link to a static library) or use a dynamic library version of Boost (see for example here on how to set that up on Windows).


1 Note that some libraries ignore those flags outright. Boost.Log seems to be one of the few that actually cause issues if these macros are misconfigured

hlt
  • 6,219
  • 3
  • 23
  • 43