Boost logo

Boost Users :

Subject: Re: [Boost-users] Why "Mixing a dll boost library with a static runtimeis a really bad idea..."?
From: John Maddock (john_at_[hidden])
Date: 2009-03-13 13:05:07

> I want (need) to use boost libs as dll with a static run-time library. In
> this case auto_link.hpp gives me an error "Mixing a dll boost library with
> a
> static runtime is a really bad idea...". Why is it a bad idea? I don't
> think
> that it's a good idea but requirements in our project demand
> static-runtime
> linkage for all modules and they don't want to use regex as static library
> cause of it's size. What problems could it cause? I know only one problem
> with a memory allocation in different modules. Any more?

It absolutely *will* cause your program to crash if you do that: the dll and
the application will have different runtime libraries, different memory
allocators etc. The only way you *might* get away with it, is if all the
API's you call are extern "C" functions, so that you can guarantee that no
memory is ever allocated in one and freed in the other module - that's
something you can't achieve with C++ API's because you don't know what will
be expanded inline and in which module.

BTW, Boost.Regex adds about 50K to an application when statically linked,
that's a lot less than the dll adds!

Regards, John.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at