Binding error: ambiguous libboost * .lib vs boost * .lib

I am using boost in my project. I uploaded precompiled binaries here http://boost.teeks99.com/

When linking, I get this 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 does boost contain two lib with such a 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 a binding error?

upd I compiled myself. I added the boost_1_53_0\stage\lib directory to the 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 that’s clear what the compiler is saying. Somehow, he cannot figure out which version of the lib file to use. This is probably due to static / dynamic linking, but I still can't find a solution. I am sure that my problems are quite common, so I hope someone can suggest me what to do.

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

I tried to delete all the "boost * lib" files from the folder, but then I get the following 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 get a lot of errors:

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)

Therefore, when there is no boost_thread-vc110-mt-1_53.lib compiler claiming to be absent, when there is boost_thread-vc110-mt-1_53.lib compiler claims that "the function is already defined". Tried it, somehow I use dynamic and static binding at the same time or something like that?

upd2 I uncommented #define BOOST_ALL_DYN_LINK , as suggested here , and now the code compiles! I am investigating whether everything is in order. however, I did not understand why I should uncomment #define BOOST_ALL_DYN_LINK , so comments are welcome.

+7
source share
4 answers

ask yourself. need to uncomment #define BOOST_ALL_DYN_LINK (see description)

0
source

Edit: The original statement was deleted because editing the message changed the situation.

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

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

You only need to use one of them.

+5
source

I think that first of all you need to fix your question. You mean (I think you already know the difference between a DLL and a LIB )

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

or

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

In any case, the problem seems to be that you are mixing the static ( libboost_thread-vc110-mt-1_52.lib ) and the general ( boost_thread-vc110-mt-1_52.lib ) boost libraries. But without a working environment and platform details, I can’t name the exact solution. If you are working in Visual Studio , you can go to right click on project file > properties > linker > input > ignore specific library and add libboost_thread-vc110-mt-1_52.lib and try it.

0
source

Another idea / solution to try if you click on the error error LNK1104: cannot open file 'libboost_date_time-*.lib' :

In our project, we include the boost/date_time.hpp . We define the constant BOOST_ALL_NO_LIB instead of BOOST_ALL_DYN_LINK in our project settings to tell boost not to automatically choose which library to reference. See the Boost documentation for more information on this option.

So you can add BOOST_ALL_NO_LIB to Project Properties -> C / C ++ -> Preprocessor -> Preprocessor Definitions and check if this linker error has disappeared.

0
source

All Articles