error LNK1104: cannot open file 'libboost_thread-vc100-mt-gd-1_55.lib'
Asked Answered
S

3

6

I'm trying to link the shared library of boost thread into my application.

System: Windows8

IDE: Visual Studio 2010

I build the boost library using:

b2 --with-thread --build-type=complete link=shared

I can see the

boost_thread-vc100-mt-gd-1_55.dll
boost_thread-vc100-mt-gd-1_55.lib

and other file inside the stage/lib directory

I've added the path to Additional Library Directories and Input in linker option as:

Additional Library Directories: C:/boost_1_55_0_dyn/stage/lib

Input: C:\boost_1_55_0_dyn\stage\lib\boost_thread-vc100-mt-gd-1_55.lib

I don't know why on the earth Visual Studio is looking for libboost_thread-vc100-mt-gd-1_55.lib. I haven't mentioned the libboost_thread-vc100-mt-gd-1_55.lib anywhere in the properties or any place. I even search all my files and folders inside the project, libboost_thread-vc100-mt-gd-1_55.lib is not mentioned anywhere.

Samson answered 18/3, 2014 at 8:27 Comment(5)
Project + Properties, C/C++, Code Generation, Runtime Library setting. Use /MD to match your link=shared bjam command. If you want /MT then you also need to build boost with link=staticVoltammeter
@Hans Passant ...and runtime-link=static.Renoir
@IgorR. what does runtime-link=static has to do with shared library?Samson
It has to do with static runtime linking.Renoir
well If i wanted static linking, i wouldn't even have put this question here. anyway I got solution to the problem already. :)Samson
S
7

Well I forgot to put BOOST_ALL_DYN_LINK in preprocessor definition. If the BOOST_ALL_DYN_LINK is not defined, boost looks for static library, that is why its looking for libboost_thread-vc100-mt-gd-1_55.lib

Samson answered 19/3, 2014 at 4:17 Comment(2)
After putting BOOST_ALL_DYN_LINK in pre-processor in Project + Properties, C/C++,pre-processor, pre-processor definitions still got error fatal error LNK1104: cannot open file 'boost_thread-vc100-mt-gd-1_55.lib'Diantha
To add to it, this error will happen even if you simply include the library directory, but don't actually use any of the libraries. I was having this error thrown on boost_system even though I wasn't even using it.Grouch
S
1

This is additional information to the answer Pritesh already posted, but I'm new here so I can't comment.

It boils down to compatibility between your VS project settings and the way the boost libraries were built. It gets a little tricky because boost and VS do some autolinking for you. Check out the file …\Include\boost\config\Auto_link.hpp. It explains the algorithms and macros that will cause libraries that you didn't explicitly include to show up in your project.

For example, BOOST_ALL_DYN_LINK is used to help determine if the boost library name should have "lib" pre-pended to the name during autolink.

Sunnysunproof answered 4/3, 2015 at 21:8 Comment(0)
J
0

Additionally ,

If you are using cmake and qibuild you can try this :

It automatically links with the corresponding libraries and make their headers available.

qi_use_lib(yourProgramName your libraries)

like this:

qi_use_lib(getimages ALCOMMON ALPROXIES ALVISION OPENCV2_CORE OPENCV2_HIGHGUI OPENCV2_IMGPROC)
Jebel answered 12/4, 2016 at 14:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.