Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
632 views
in Technique[技术] by (71.8m points)

Linker problem linking boost in Visual Studio 2008

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...