周洪宇
周洪宇

Reputation: 13

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

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)

Upvotes: 1

Views: 3047

Answers (1)

hlt
hlt

Reputation: 6317

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

Upvotes: 3

Related Questions