Why "Mixing a dll boost library with a static runtime is a really bad idea..."?
Hi, 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? Thanks, Vladimir
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.
It absolutely *will* cause your program to crash if you do that: the dll and the application will have different runtime libraries
The OP says he wants to use boost libs as DLLs, but with static runtime. Isn't it possible to build boost with "link=shared runtime-link=static" ? Then the dll and the application would have the same runtime libraries.
It absolutely *will* cause your program to crash if you do that: the dll and the application will have different runtime libraries
The OP says he wants to use boost libs as DLLs, but with static runtime. Isn't it possible to build boost with "link=shared runtime-link=static" ? Then the dll and the application would have the same runtime libraries.
No they wouldn't: or at least they would have *different instances* of the same code, with all the same problems. John.
participants (3)
-
D M
-
Igor R
-
John Maddock