So after struggling for hours to get a working C++ driver for MongoDB
(Windows w/ VS 2008), I'm at the end of my patience. Here's what I
did:
1. Downloaded the MongoDB 1.6.0 source code.
2. Installed and built all the necessary Boost 1.42 libraries.
3. Installed Python 2.6.5 and SCons 1.2.0.
4. Downloaded the SpiderMonkey 1.7.0 source code.
5. Built SpiderMonkey using the SCons script from mongodb/snippets.
6. Built MongoDB 1.6.0 client driver by executing "scons
mongoclient".
In my VS 2008 C++ project, I link to the driver using '#pragma
comment(lib, "mongoclient.lib")'. When I do a standard debug build,
everything works fine. However, when I do a standard release build,
as soon as I create a mongo::DBClientConnection object, it crashes
with the following:
HEAP[VIS.exe]: Invalid allocation size - CCCCCC10 (exceeded 7ffdefff)
First-chance exception at 0x7c812afb in VIS.exe: Microsoft C++
exception: std::bad_alloc at memory location 0x0012e6b0..
HEAP[VIS.exe]: Invalid allocation size - CCCCCC01 (exceeded 7ffdefff)
First-chance exception at 0x7c812afb in VIS.exe: Microsoft C++
exception: std::bad_alloc at memory location 0x0012e050..
First-chance exception at 0x7c812afb in VIS.exe: Microsoft C++
exception: [rethrow] at memory location 0x00000000..
Also, if I redo step 6 with "scons --release mongoclient", I am unable
to link to the resulting client library.
Following is a sampling of the errors I get. There have been other
posts with the same errors in previous versions. I have tried various
solutions such as ignoring libcmt.lib and msvcrt.lib, but they just
produce other linker errors.
1>mongoclient-release.lib(dbclient.obj) : error LNK2005: "public:
class std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> > __thiscall std::basic_stringstream<char,struct
std::char_traits<char>,class std::allocator<char> >::str(void)const
" (?str@?$basic_stringstream@DU?$char_traits@D@std@@V?
$allocator@D@2@@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?
$allocator@D@2@@2@XZ) already defined in msvcprt.lib(MSVCP90.dll)
1>LIBCMT.lib(crtheap.obj) : error LNK2005: __malloc_crt already
defined in MSVCRT.lib(MSVCR90.dll)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> > & __thiscall std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> >::operator+=(class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> > const &)" (??Y?$basic_string@DU?
$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@ABV01@@Z) already
defined in mongoclient-release.lib(dbclient.obj)
Any help would be appreciated as I've experienced similar issues with
MongoDB version 1.4.4.