Boost C++ Libraries: Ticket #6642: Windows: auto_link.hpp incorrectly hardstops with error "Mixing a dll boost library with a static runtime is a really bad idea..." https://svn.boost.org/trac10/ticket/6642 <p> 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. </p> <p> According to "/MD, /MT, /LD (Use Run-Time Library)", <a class="ext-link" href="http://msdn.microsoft.com/en-US/library/2kzt1wy3(v=vs.90).aspx"><span class="icon">​</span>http://msdn.microsoft.com/en-US/library/2kzt1wy3(v=vs.90).aspx</a>: </p> <p> /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. </p> <p> /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. </p> <p> Somehow, Boost is auto-configuring itself as if "_DLL" was defined in my dynamic link library (which it is not). </p> <p> Perhaps the following would be a better test (sorry, I could not figure out the Boost specific stuff): </p> <p> #if defined(BOOST_OS_WINDOWS) &amp;&amp; defined(_MT) &amp;&amp; !defined(_DLL) # define BOOST_OS_WINDOWS_STATIC 1 #elif defined(BOOST_OS_WINDOWS) &amp;&amp; defined(_MT) &amp;&amp; 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 </p> <p> Note that the above does not touch upon DLL's and <a class="missing wiki">Import/Export</a> headers - just the static and dynamic linking to the runtime </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6642 Trac 1.4.3 John Maddock Fri, 02 Mar 2012 13:13:47 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6642#comment:1 https://svn.boost.org/trac10/ticket/6642#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">duplicate</span> </li> </ul> <p> Duplicates <a class="new ticket" href="https://svn.boost.org/trac10/ticket/6644" title="#6644: Bugs: Windows: auto_link.hpp incorrectly errors with &#34;Mixing a dll boost ... (new)">#6644</a>. </p> Ticket