statically linking to Boost.Threads with msvc7
I've built and installed boost on a WinXp system with VS.Net 2003. I'm trying to use it in a static CRT project. I get the following error whenever I compile:
error C1189: #error : "Mixing a dll boost library with
a static runtime is a really bad idea..."
I noticed that this is happening because BOOST_DYN_LINK is #defined in config.hpp. Apparently dynamic linking is the default for Boost? Anyway, I've commented out this #define, but now I get a ton of warnings like the following
warning C4275: non dll-interface class 'std::logic_error'
used as base for dll-interface class 'boost::lock_error'
and the project won't link
error LNK1104: cannot open file
'libboost_thread-vc71-mt-s-1_31.lib' I looked in Boost's lib folder and there aren't any static thread binaries (eg, "libboost_thread_xxx.lib). There are only the dynamic libraries (boost_thread_xxx.lib). Apparently something failed in the build process. I have to admit I didn't sit and watch the build process for the half-hour it took to build, so something may have gone wrong. Is there a build log somewhere? Is it possible to have bjam only build Boost.Threads so that I can see if there's an error without having to rebuild the entire library? Thanks, Aaron Simmons
Simmons, Aaron wrote:
I’ve built and installed boost on a WinXp system with VS.Net 2003. I’m trying to use it in a static CRT project. I get the following error whenever I compile:
error C1189: #error : "Mixing a dll boost library with
a static runtime is a really bad idea..."
I noticed that this is happening because BOOST_DYN_LINK is #defined in config.hpp. Apparently dynamic linking is the default for Boost?
Anyway, I’ve commented out this #define, but now I get a ton of warnings like the following
warning C4275: non dll-interface class 'std::logic_error' used as base for dll-interface class 'boost::lock_error'
and the project won’t link
error LNK1104: cannot open file
'libboost_thread-vc71-mt-s-1_31.lib'
I looked in Boost’s lib folder and there aren’t /any/ static thread binaries (eg, “libboost_thread_xxx.lib). There are only the dynamic libraries (boost_thread_xxx.lib). Apparently something failed in the build process. I have to admit I didn’t sit and watch the build process for the half-hour it took to build, so something may have gone wrong. Is there a build log somewhere? Is it possible to have bjam only build Boost.Threads so that I can see if there’s an error without having to rebuild the entire library?
In Boost release 1.31, the Boost.Threads library doesn't support static linking. This limitation will be removed in the next release (coming soon) for: a) anyone using the pthreads implementation of Boost.Threads b) anyone using Visual C++ on Win32 Hopefully it will be removed for other Win32 compilers in the future. Mike
participants (2)
-
Michael Glassford
-
Simmons, Aaron