Subject: [Boost-bugs] [Boost C++ Libraries] #6642: Windows: auto_link.hpp incorrectly hardstops with error "Mixing a dll boost library with a static runtime is a really bad idea..."
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-03-01 22:59:14
#6642: Windows: auto_link.hpp incorrectly hardstops with error "Mixing a dll boost
library with a static runtime is a really bad idea..."
--------------------------------+-------------------------------------------
Reporter: noloader@⦠| Owner: johnmaddock
Type: Bugs | Status: new
Milestone: To Be Determined | Component: config
Version: Boost 1.49.0 | Severity: Problem
Keywords: |
--------------------------------+-------------------------------------------
I'm building a DLL which uses *STATIC* runtime linking. This means I am
using the /MT switch, which defines "_MT" . Since I am building a DLL,
"_WINDLL" is defined.
According to "/MD, /MT, /LD (Use Run-Time Library)",
http://msdn.microsoft.com/en-US/library/2kzt1wy3(v=vs.90).aspx:
/MT - Causes your application to use the multithread, static version of
the run-time library. Defines _MT and causes the compiler to place the
library name LIBCMT.lib into the .obj file so that the linker will use
LIBCMT.lib to resolve external symbols.
/MD - Causes your application to use the multithread- and DLL-specific
version of the run-time library. Defines _MT and _DLL and causes the
compiler to place the library name MSVCRT.lib into the .obj file.
Applications compiled with this option are statically linked to
MSVCRT.lib. This library provides a layer of code that allows the linker
to resolve external references. The actual working code is contained in
MSVCR90.DLL, which must be available at run time to applications linked
with MSVCRT.lib.
From the documentation, "_MT" is always defined, regardless of whether
using static or dynamic runtime libraries). "_DLL" is defined when using
dynamic runtime libraries.
Somehow, Boost is auto-configuring itself as if "_DLL" was defined in my
dynamic link library (which it is not).
Perhaps the following would be a better test (sorry, I could not figure
out the Boost specific stuff):
#if defined(BOOST_OS_WINDOWS) && defined(_MT) && !defined(_DLL)
# define BOOST_OS_WINDOWS_STATIC 1
#elif defined(BOOST_OS_WINDOWS) && defined(_MT) && defined(_DLL)
# define BOOST_OS_WINDOWS_DYNAMIC 1
#elif defined(BOOST_OS_WINDOWS)
# pragma warning("Neither static nor dynamic runtime linking has been
picked up")
#endif
Note that the above does not touch upon DLL's and Import/Export headers -
just the static and dynamic linking to the runtime
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/6642> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC