[Boost-bugs] [Boost C++ Libraries] #6644: Windows: auto_link.hpp incorrectly errors with "Mixing a dll boost library with a static runtime is a really bad idea..."

Subject: [Boost-bugs] [Boost C++ Libraries] #6644: Windows: auto_link.hpp incorrectly errors with "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 23:42:09


#6644: Windows: auto_link.hpp incorrectly errors with "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.48.0 | Severity: Problem
 Keywords: Windows auto_link /MT /MD DLL |
-------------------------------------------+--------------------------------
 I'm building a DLL which uses *static* runtime linking. Static runtime
 linking uses the /MT (and /MTd) switch. When Boost is compiled with under
 the DLL, the following error is reported:

 C:\Users\Public\boost-trunk\boost/config/auto_link.hpp(354) : fatal error
 C1189: #error : "Mixing a dll boost library with a static runtime is a
 really bad idea..."

 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.

 For completeness, here is the switch for dynamic runtime linking:

 /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...

 To summarize, "_MT" is defined for both static and dynamic linking. "_DLL"
 is defined for just dynamic linking. And because I am building a DLL,
 "_WINDLL" is also defined.

 Perhaps the following would be better logic for auto_link.hpp (my
 apologies for not trying to figure out all the Boost defines):

 #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

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6644>
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