Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are Boost Debug and Release Libraries the same?

Tags:

c++

boost

My project uses boost-win-1.47-32bit-vs2010 libraries. I am currently running my application in debug mode and it seems to run fine.Now I am planning to build it in release mode and I successfully did that also. However my concern is I did that using the same boost libraries.I never built the boot libraries so I do not know whether the boot libraries I am using is for debug mode or release mode. Any suggestions on how I could find out. Is it possible that the boot libraries I am using was meant to run in both the release and debug mode since I do not get any errors when I change modes ?

Update:

There seems to be two versions of each file in the relevant folder for instance

libboost_thread-vc100-mt-1_47.lib

libboost_thread-vc100-mt-gd-1_47.lib

Does this mean it contains both the debug and release libraries. Since I do not explicitly specify anything in the input properties other than the path to the folder in VS2010. I think there might be a chance that I overlooked the fact that the folder contains both the Release and the debug version and when I change the build option to debug it build using the boost debug libraries and when I build using the release option it builds using the release libraries.

like image 299
MistyD Avatar asked Jun 19 '13 20:06

MistyD


2 Answers

Is it possible that the boot libraries I am using was meant to run in both the release and debug mode

No, not really. You will have a debug and a release build. You should not mix those.

The libboost_thread-vc100-mt-1_47.lib will be your release build of the library. The release version of your application should link against that one. For the debug build you can link against libboost_thread-vc100-mt-gd-1_47.lib.

Your compiler might not directly complain about anything, but at runtime several C++ runtime related problems can arise. See for example this post: Mixing debug and release library/binary - bad practice?

like image 158
Bart Avatar answered Sep 25 '22 04:09

Bart


Boost will typically build both debug and release libraries by default and install them both in the library install directory. (Usually c:\Boost\lib on windows or /usr/local on unix/linux, etc). However, this behaviour can be changed, so you should check.

If you look in the library you should see both versions for every library, for example:

libboost_unit_test_framework-vc110-mt-1_53.lib
libboost_unit_test_framework-vc110-mt-gd-1_53.lib

The first one above is the release version of the library, while the -gd in the seconds indicates a debug build, see this page for the naming convention used.

Now, you must make sure you link with the correct version of the library. If you are using Visual Studio, then it will select the correct library for you. For other toolsets you must explicitly choose the correct library to link with for each build configuration.

Note: Visual Studio includes a pragma option to specify what library an object file should link against. Boost makes use of this option via the auto_link.hpp header file which will be included for you if you use a boost library that has a library to link against.

like image 23
zdan Avatar answered Sep 23 '22 04:09

zdan