C++ – linking error: ambiguous libboost*.lib vs boost*.lib

boostc

I'm using boost in my project. I've downloaded pre-compiled binaries from here http://boost.teeks99.com/

When linking I receive such error:

Error 18 error LNK2005: "public: void __cdecl boost::thread::join(void)" (?join@thread@boost@@QEAAXXZ) already defined in boost_thread-vc110-mt-1_52.lib(boost_thread-vc110-mt-1_52.dll) C:\Oleg\projects\MBClient\FastNativeAdapter\libboost_thread-vc110-mt-1_52.lib(thread.obj) FastNativeAdapter

Why boost contains two lib with so similar name, what is the difference between them?

  • libboost_thread-vc110-mt-1_52.lib
  • boost_thread-vc110-mt-1_52.lib

How to fix linking error?

upd I've compiled boost myself. I've added boost_1_53_0\stage\lib directory to linker. This directory actually contains 3 "copies" of "each" file, for example:

  • boost_atomic-vc110-mt-1_53.dll
  • boost_atomic-vc110-mt-1_53.lib
  • libboost_atomic-vc110-mt-1_53.lib

So It's clear what compiler claims about. Somehow it can't understand which version of lib file to use. It's likely connected with static/dinamic linking, but I still can not find the solution. I'm sure my problems is pretty common so I hope someone can suggest me what to do.

I've tried to delete all "libboost*" files from folder but then I receive such error:
Error 15 error LNK1104: cannot open file 'libboost_date_time-vc110-mt-1_53.lib'

I've tried to delete all "boost*lib" files from folder but then I receive such error:
Error 15 error LNK1104: cannot open file 'boost_thread-vc110-mt-1_53.lib'

Then I copied boost_thread-vc110-mt-1_53.lib back and I receive a lot of errors like that:

Error 16 error LNK2005: "public: virtual __cdecl boost::detail::thread_data_base::~thread_data_base(void)" (??1thread_data_base@detail@boost@@UEAA@XZ) already defined in boost_thread-vc110-mt-1_53.lib(boost_thread-vc110-mt-1_53.dll)

So when there are no boost_thread-vc110-mt-1_53.lib compiler claims that it's missing, when there is boost_thread-vc110-mt-1_53.lib compiler claims that "function is already defined". Probaly somehow I do use dinamic and static linking at the same time or something like that?

upd2 i've uncommented #define BOOST_ALL_DYN_LINK as suggested here and now code compiles! i'm investigating if everything else is fine. however i didn't understand why I should uncomment #define BOOST_ALL_DYN_LINK so comments are welcome.

Best Answer

Edit: Initial statement removed since an edit to the post changed the situation.

Based on http://www.boost.org/doc/libs/1_53_0/more/getting_started/unix-variants.html#library-naming (as provided by Igor R.):

libboost_thread-vc110-mt-1_52.lib is a static lib (no need for the DLL) boost_thread-vc110-mt-1_52.lib is the import lib for the DLL

You only need to use one of these.

Related Topic