Linker problem linking boost in Visual Studio 2008

2019-08-29 23:46发布

I have a rather obscure linking problem in Visual Studio 2008. The linker error message is: "LNK1104: cannot open file 'boost_thread-vc90-mt-gd-1_38.lib'". All pathes and dependencies are set. What I noticed though is that Visual Studio misses boost_thread-vc90-mt-gd-1_38.lib and not libboost_thread-vc90-mt-gd-1_38.lib (notice the lib at the beginning of the file name). I added the .lib as libboost_thread-vc90-mt-gd-1_38.lib to the project and it appears as libboost_thread-vc90-mt-gd-1_38.lib in the command line.

Why does Visual Studio the beginning of the file name?

1条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-08-30 00:26

There is a rule for naming libraries in Boost:

1) boost_thread-vc90-mt-gd-1_38.lib for dynamically linked version 2) libboost_thread-vc90-mt-gd-1_38.lib for statically linked version

BOOST_LIB_PREFIX: "lib" for static libraries otherwise "".

There is a preprocessor define that you can define in your project in order to use the dynamically linked version of a boost library BOOST_DYN_LINK=1

It has this description:

BOOST_DYN_LINK: Optional: when set link to dll rather than static library.

Another define that tells to use the dynamic version of Boost.Thread is BOOST_THREAD_USE_DLL

查看更多
登录 后发表回答