TLDR
Linking my fresh boost build with Visual Studio (/Mtd) causes boost to throw a 'bad_alloc' exception before entering the main function.
Details
I built the boost library using the instructions from the Getting Started instructions. After setting up the prerequisites I used the following build command:
bjam -j8 --build-dir="C:\Development\Boost\boost-build" --build-type=complete msvc stage
Above command seems to build all combinations of debug/release and shared/static builds.
Then I created a empty Visual Studio project and added the following code in the main file:
#include <boost/thread.hpp>
int main()
{
return 0;
}
I also changed the Code Generation settings to Multi-threaded Debug (/MTd).
At this point I did not yet configure any library paths in my project. So the build ended with the following linker error:
LINK : fatal error LNK1104: cannot open file 'libboost_thread-vc90-mt-sgd-1_43.lib'
Ok, I find this file in my boost build and copy it to '$(SolutionDir)3rdParty\Boost_1_43_0\libs' which I added to the Additional Library Directories. Next error follows:
LINK : fatal error LNK1104: cannot open file 'libboost_date_time-vc90-mt-sgd-1_43.lib'
Ok, I also find this file in my boost build directory and copy it to my library path.
After this the project builds succesfully, but a 'bad_alloc" exception is thrown in boost code, before entering the main function.
It seems that there is a library incompatibility here. Does anyone know what exactly is going wrong, and how to fix it?
Update
Since James McNellis mentioned that this may be something specific to the thread library I tried out 'program_options' and this one doesn't cause any problems (main body is still empty though).
A simple sample application using the boost 'signal' library works fine also. So it's really the thread library that's causing some problem.
Version
I'm currently using Boost v1.43.0, I'll see if I can reproduce the problem with v1.42.
BCP
One detail I'd like to mention is that I am using a stripped down version of Boost. I created a subset using the following bcp utility:
mkdir ./output
bcp bind function lexical_cast noncopyable optional program_options smart_ptr signals signals2 thread ./output
This probably isn't causing the 'bad_alloc' though...
Boost 1.42
I just installed Boost 1.42 using the BoostPro Installer. A quick test revealed that it works fine like this. Strange...