Re: [Boost-users] Boost Static Linking Woes

Hello everyone, I am sorry, I did not explain my situation as well as I should have. I have a complete build of boost installed so I had assumed it created static libraries alongside dynamic ones. When I received the "Mixing a dll boost library with a static runtime is a really bad idea..." message I had assumed autolink was to blame because I had assumed it would recognize the static install and thus search for the static libraries. When I disabled autolink I directly linked to "libboost_whatever.lib" as those are the static libraries correct? However that's when I received the heap corruption. As for the macros... I checked my user & config files, and BOOST_ALL_DYN_LINK was commented out.
That suggests a build problem somewhere: do you still have BOOST_ALL_DYN_LIB defined or something?
By still, do you mean that it is defined by default? Because I had never undefined it. Does boost complete build both static and dynamic libraries? Because maybe that is my problem. I appreciate everyone's help. Thanks, -Brian.

On Wed, Nov 12, 2008 at 10:33 PM, Brian Dawn
Hello everyone, I am sorry, I did not explain my situation as well as I should have. I have a complete build of boost installed so I had assumed it created static libraries alongside dynamic ones. When I received the "Mixing a dll boost library with a static runtime is a really bad idea..." message I had assumed autolink was to blame because I had assumed it would recognize the static install and thus search for the static libraries. When I disabled autolink I directly linked to "libboost_whatever.lib" as those are the static libraries correct? However that's when I received the heap corruption.
As for the macros... I checked my user & config files, and BOOST_ALL_DYN_LINK was commented out.
That suggests a build problem somewhere: do you still have BOOST_ALL_DYN_LIB defined or something?
By still, do you mean that it is defined by default? Because I had never undefined it.
Does boost complete build both static and dynamic libraries? Because maybe that is my problem.
I appreciate everyone's help. Thanks, -Brian.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
The boost libraries are usually linked against the shared C++ runtime (compiled with /MD), unless you explicitly specify something else with bjam. Your application should be linked to the same version of the C++ runtime. If you really want to link your application against the static runtime (compile with /MT) I guess you have to build boost with this flag too. IIRC it is done by specifying runtime-link=static to bjam when building boost. Did you do this yet? After doing this, I guess there is some "magic" preprocessor define you need to specify in your project, so the boost config header becomes aware of what boost variant you are using... Hope this helps, Thomas

Brian Dawn wrote:
That suggests a build problem somewhere: do you still have BOOST_ALL_DYN_LIB defined or something?
By still, do you mean that it is defined by default? Because I had never undefined it.
No, I mean you won't see that message from the auto-linking code unless: * You are linking to a static runtime, *and* * You have either BOOST_ALL_DYN_LINK or BOOST_<libname>_DYN_LINK defined somewhere. I believe the only exception to this is Boost.Python, but that has special requirements that make static linking much more tricky I believe.
Does boost complete build both static and dynamic libraries? Because maybe that is my problem.
If you built with "--build-type=complete" then yes. The static libs all start with the prefix "lib", and the dll import libs do not. HTH, John.
participants (3)
-
Brian Dawn
-
John Maddock
-
Thomas Berg