views:

140

answers:

4

I have built Boost in Release configuration and have staged it into one folder. Now when I add Boost libraries into project and try to build it in Debug configuration - linker fails because there are no Debug versions libraries.

Is there a way to make MSVC 9.0 use Release version of libraries when building Debug configuration?

Of course, there is an easy soultion - build Debug version of Boost. But I am just curious.

A: 

Exclude debug libs boost tries to link in (or disable with a preprocessor define, look into config.hpp) and manually include release versions.

That is, you could try that if not for runtime conflict...

(so that's a no)

Eugene
+3  A: 

You can do two things:

  • Build the debug version for boost (this is the best option).
  • Add debugging symbols to your release build.

You can't use the release version of boost with your debug build because boost depends on the CRT, which is different in debug/release builds.

rpg
A: 

I've just ran into this as well, and I have something to add:

I think the answer lies in boost\config\auto_link.hpp. It looks like including this file (which probably happens for all .lib / .dll, non-header-only, libraries) makes the generated .obj refer the debug version of the library.

Defining BOOST_ALL_NO_LIB will allow the linking to succeed, having the debug version of the program linked against the release version of the library. However, when actually trying to use Boost serialization linked like this I got an "Access violation reading location 0xabababeb", meaning that some pointer was left uninitialized. Perhaps this can be fixed by compiling something else in release mode, but it's probably better to just use Boost debug.

A: 

1st... This is probably a bad idea, just build the debug libraries (or you can get them from my site).

If you still want to continue, try going in to the project properties -> Configuration Properties -> C\C++ -> Code Generation. Your "Runtime Library" setting will probably be something like "Multi-threaded Debug DLL (/MDd)", try changing this to the comperable option without the "Debug" in it and re-build.

I haven't actually gotten to try this myself, but I think it should work. I'm curious if you're successful :-)

teeks99