Error building the newest c++ driver for Mongo

3,166 views
Skip to first unread message

Mick

unread,
Oct 24, 2012, 3:01:12 PM10/24/12
to mongo...@googlegroups.com
Hi,
I'm following the instructions on the mongo web site and I run "scons mongoclient", but this is what I'm getting:
 
   scons: Reading SConscript files ...
   Checking for C++ library boost_thread-mt... (cached) no
   Checking for C++ library boost_thread... (cached) no
   Checking for C++ library boost_filesystem-mt... (cached) no
   Checking for C++ library boost_filesystem... (cached) no
   Checking for C++ library boost_system-mt... (cached) no
   Checking for C++ library boost_system... (cached) no
   scons: done reading SConscript files.
   scons: Building targets ...
   cl /Fobuild\mongo\bson\oid.obj /c src\mongo\bson\oid.cpp /nologo /EHsc /O2 /TP /
   nologo /EHsc /O2 /D_SCONS /DMONGO_EXPOSE_MACROS /Ibuild /Isrc /Ibuild\mongo /Isr
   c\mongo
   'cl' is not recognized as an internal or external command,
   operable program or batch file.
   scons: *** [build\mongo\bson\oid.obj] Error 1
   scons: building terminated because of errors.
 
The path is set, because if I type cl in that folder it comes up with:
   cl
   Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
   Copyright (C) Microsoft Corporation.  All rights reserved.
   usage: cl [ option... ] filename... [ /link linkoption... ]
 
Please help.
 
Thank you in advance :)
 
 

Eric Milkie

unread,
Oct 24, 2012, 3:13:50 PM10/24/12
to mongo...@googlegroups.com
Hi Mick,
scons doesn't use the PATH variable to find the compiler (the MongoDB SConstruct doesn't import the PATH variable into its internal environment).  
Do you have Visual Studio installed in an unusual place?
-Eric



--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-dev/-/eBiu8r1kckUJ.
To post to this group, send email to mongo...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-dev...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-dev?hl=en.

Mick

unread,
Oct 24, 2012, 4:05:44 PM10/24/12
to mongo...@googlegroups.com
Hi Eric,
Visual Studio is installed in the default location, nothing special about it...
I'm using Visual Studio 2008.

Eric Milkie

unread,
Oct 25, 2012, 1:20:34 PM10/25/12
to mongo...@googlegroups.com
Which version of scons?  The places that it looks for executables is actually built in to scons itself, so it's important to make sure you're on the latest version.
If you're all up to date, then the next step is to tell scons to print out debugging info for how it determines where cl.exe is.  Or we can just import the PATH by adding a few lines to the SConstruct:
http://www.scons.org/wiki/FrequentlyAskedQuestions#Why_doesn.27t_SCons_find_my_compiler.2BAC8-linker.2BAC8-etc..3F_I_can_execute_it_just_fine_from_the_command_line.

Mick

unread,
Oct 25, 2012, 5:03:10 PM10/25/12
to mongo...@googlegroups.com
I had an older version of Scons, so I got the latest one, and now it comes up with a different error message:
 
src\mongo/pch.h(48) : fatal error C1083: Cannot open include file: 'boost/shared_ptr.hpp': No such file or directory
scons: *** [build\mongo\bson\oid.obj] Error 2
scons: building terminated because of errors
 
I haven't moved anything, just downloaded the C++ driver tar from Mongo site, it comes with a boost folder, where should that be so Scons will find the files it needs?
 
Thank you.

Eric Milkie

unread,
Oct 25, 2012, 5:16:37 PM10/25/12
to mongo...@googlegroups.com
Ok I would make sure you've checked over the instructions here first:
It shows what things need to be installed and what versions are required (like for scons).

That include file should already be in the path for the compiler, so you shouldn't have to move anything, as long as your setup is correct.
-Eric


--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-dev/-/i6juyxYAvaAJ.

gli

unread,
Oct 26, 2012, 3:54:49 PM10/26/12
to mongo...@googlegroups.com
Hi Mick,
 
I built mongo-cxx-driver-v2.2, using scons-2.2.0, boost_1_45_0, and VS 2010.
 
Before you run scons, you need to set the boost path in SConstruct file, in mongo-cxx-driver-v2.2 directory:
 

env.Append(CPPPATH=your_boost_root_directory)

env.Append(LIBPATH=your_boost_libs_directory)

 

The is the command I ran scons:

 

scons.bat mode=release mongoclient.lib

 

Please give it a try, and let us know.

 

gli

Mick

unread,
Oct 29, 2012, 11:43:46 AM10/29/12
to mongo...@googlegroups.com
Thank you all for your help, I was finally able to build mongoclient.lib.  I'm using C++, VS2008, boost 1_49 and mongo 2.2.
However, I added the lib to my project, and now I'm getting these link errors:
 

mongoclientd.lib(log.obj) : error LNK2019: unresolved external symbol "class boost::filesystem2::file_status __cdecl boost::filesystem2::detail::status_api(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class boost::system::error_code &)" (?status_api@detail@filesystem2@boost@@YA?AVfile_status@23@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAVerror_code@system@3@@Z) referenced in function "bool __cdecl boost::filesystem2::exists<class boost::filesystem2::basic_path<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct boost::filesystem2::path_traits> >(class boost::filesystem2::basic_path<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct boost::filesystem2::path_traits> const &)" (??$exists@V?$basic_path@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@Upath_traits@filesystem2@boost@@@filesystem2@boost@@@filesystem2@boost@@YA_NABV?$basic_path@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@Upath_traits@filesystem2@boost@@@01@@Z)

2>mongoclientd.lib(util.obj) : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAABVerror_category@12@XZ)

2>mongoclientd.lib(dbmessage.obj) : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAABVerror_category@12@XZ)

2>mongoclientd.lib(log.obj) : error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAABVerror_category@12@XZ) referenced in function "public: __thiscall boost::system::error_code::error_code(void)" (??0error_code@system@boost@@QAE@XZ)

2>mongoclientd.lib(syncclusterconnection.obj) : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAABVerror_category@12@XZ)

2>mongoclientd.lib(dbclient_rs.obj) : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAABVerror_category@12@XZ)

2>mongoclientd.lib(dbclientcursor.obj) : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAABVerror_category@12@XZ)

2>mongoclientd.lib(util.obj) : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAABVerror_category@12@XZ)

2>mongoclientd.lib(dbmessage.obj) : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAABVerror_category@12@XZ)

2>mongoclientd.lib(log.obj) : error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAABVerror_category@12@XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'posix_category''(void)" (??__Eposix_category@system@boost@@YAXXZ)

2>mongoclientd.lib(syncclusterconnection.obj) : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAABVerror_category@12@XZ)

2>mongoclientd.lib(dbclient_rs.obj) : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAABVerror_category@12@XZ)

2>mongoclientd.lib(dbclientcursor.obj) : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAABVerror_category@12@XZ)

Eric Milkie

unread,
Oct 29, 2012, 11:49:45 AM10/29/12
to mongo...@googlegroups.com
What does your LINK command line look like?
-Eric

Mick

unread,
Oct 29, 2012, 12:24:26 PM10/29/12
to mongo...@googlegroups.com
I'm using VS2008 to build my project, link command prompt is:
 
/OUT:"c:\Archiver\build\wxp\..\..\Debug\wxp\bin\ArchiverMongoDBd.dll" /INCREMENTAL /NOLOGO /LIBPATH:"c:\Archiver\build\wxp\..\..\thirdparty\boost\wxp\debug" /DLL /MANIFEST /MANIFESTFILE:"c:\Archiver\build\wxp\..\..\Debug\wxp\obj\ArchiverMongoDBD\ArchiverMongoDBd.dll.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"c:\Archiver\Debug\wxp\bin\..\symbols\ArchiverMongoDBd.pdb" /SUBSYSTEM:CONSOLE /DYNAMICBASE /NXCOMPAT /IMPLIB:"c:\Archiver\Debug\wxp\bin\ArchiverMongoDBd.lib" /MACHINE:X86 /ERRORREPORT:PROMPT Ws2_32.lib Dbghelp.lib  kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "..\..\debug\wxp\bin\archiverloggingd.lib"

Eric Milkie

unread,
Oct 29, 2012, 1:05:47 PM10/29/12
to mongo...@googlegroups.com
I don't see mongoclient.lib listed explicitly on the command line; are you using #pragma comment to link it in?
From the linker messages, I think you are missing a link to one or more Boost libraries.
-Eric

Mick

unread,
Oct 29, 2012, 1:58:59 PM10/29/12
to mongo...@googlegroups.com
Hi Eric,
mongoclient.lib is added to the project file, and the boost path is specified in the project properties.  That worked fine with the previous version of Mongo that we were using - Mongo 2.0.6.  The only thing that changed now is the Mongo version, all the paths are the same.

Mick

unread,
Oct 29, 2012, 6:40:31 PM10/29/12
to mongo...@googlegroups.com
I made some progress, now I'm down to 5 errors and I have no idea what they mean... 
Has anybody seen these before and does anybody have any idea how to get rid of them?
Thank you in advance.
 

error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall mongo::DBClientWithCommands::getLastError(bool,bool,int,int)" (?getLastError@DBClientWithCommands@mongo@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_N0HH@Z) referenced in function "public: unsigned long __thiscall CArcDBComm::Initialize(void)" (?Initialize@CArcDBComm@@QAEKXZ)

error LNK2019: unresolved external symbol "public: static class mongo::ScopedDbConnection * __cdecl mongo::ScopedDbConnection::getScopedDbConnection(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,double)" (?getScopedDbConnection@ScopedDbConnection@mongo@@SAPAV12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@N@Z) referenced in function "public: unsigned long __thiscall CArcDBComm::Initialize(void)" (?Initialize@CArcDBComm@@QAEKXZ)

error LNK2019: unresolved external symbol "void __cdecl mongo::verifyFailed(char const *,char const *,unsigned int)" (?verifyFailed@mongo@@YAXPBD0I@Z) referenced in function "public: virtual class mongo::BSONObjBuilder & __thiscall mongo::BSONObjBuilder::append(class mongo::BSONElement const &)" (?append@BSONObjBuilder@mongo@@UAEAAV12@ABVBSONElement@2@@Z)

error LNK2019: unresolved external symbol "void __cdecl mongo::msgasserted(int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?msgasserted@mongo@@YAXHABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function __catch$?_assertInvalid@BSONObj@mongo@@ABEXXZ$0

error LNK2019: unresolved external symbol "void __cdecl mongo::uasserted(int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?uasserted@mongo@@YAXHABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: void __thiscall mongo::BSONElement::toString(class mongo::StringBuilderImpl<class mongo::TrivialAllocator> &,bool,bool,int)const " (?toString@BSONElement@mongo@@QBEXAAV?$StringBuilderImpl@VTrivialAllocator@mongo@@@2@_N1H@Z)

 

On Wednesday, October 24, 2012 12:01:12 PM UTC-7, Mick wrote:

Eric Milkie

unread,
Oct 30, 2012, 12:40:24 PM10/30/12
to mongo...@googlegroups.com
Those symbols should be coming from the mongoclient library.  For example, mongo::ScopedDbConnection::getScopedDbConnection() should be coming from connection_factory.cpp, a file that's compiled into the library.
Have you tried linking any of the example files in mongo\src\mongo\client\examples?  See if tutorial.cpp or first.cpp links, or if you get similar missing symbol errors.
-Eric

Mick

unread,
Oct 30, 2012, 3:30:55 PM10/30/12
to mongo...@googlegroups.com
Thank you for your help, Eric, I got past those errors.
Unfortunately now I get a different set:
 

1>mongoclientd.lib(stacktrace.obj) : error LNK2019: unresolved external symbol __imp__SymCleanup@4 referenced in function "void __cdecl mongo::printWindowsStackTrace(struct _CONTEXT &,class std::basic_ostream<char,struct std::char_traits<char> > &)" (?printWindowsStackTrace@mongo@@YAXAAU_CONTEXT@@AAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)

1>mongoclientd.lib(stacktrace.obj) : error LNK2019: unresolved external symbol __imp__StackWalk64@36 referenced in function "void __cdecl mongo::printWindowsStackTrace(struct _CONTEXT &,class std::basic_ostream<char,struct std::char_traits<char> > &)" (?printWindowsStackTrace@mongo@@YAXAAU_CONTEXT@@AAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)

1>mongoclientd.lib(stacktrace.obj) : error LNK2019: unresolved external symbol __imp__SymSetOptions@4 referenced in function "void __cdecl mongo::printWindowsStackTrace(struct _CONTEXT &,class std::basic_ostream<char,struct std::char_traits<char> > &)" (?printWindowsStackTrace@mongo@@YAXAAU_CONTEXT@@AAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)

1>mongoclientd.lib(stacktrace.obj) : error LNK2019: unresolved external symbol __imp__SymGetOptions@0 referenced in function "void __cdecl mongo::printWindowsStackTrace(struct _CONTEXT &,class std::basic_ostream<char,struct std::char_traits<char> > &)" (?printWindowsStackTrace@mongo@@YAXAAU_CONTEXT@@AAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)

1>mongoclientd.lib(stacktrace.obj) : error LNK2019: unresolved external symbol __imp__SymInitialize@12 referenced in function "void __cdecl mongo::printWindowsStackTrace(struct _CONTEXT &,class std::basic_ostream<char,struct std::char_traits<char> > &)" (?printWindowsStackTrace@mongo@@YAXAAU_CONTEXT@@AAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)

1>mongoclientd.lib(stacktrace.obj) : error LNK2019: unresolved external symbol __imp__SymGetModuleInfo64@16 referenced in function "void __cdecl mongo::getModuleName(void *,unsigned __int64,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?getModuleName@mongo@@YAXPAX_KPAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

1>mongoclientd.lib(stacktrace.obj) : error LNK2019: unresolved external symbol __imp__SymGetLineFromAddr64@20 referenced in function "void __cdecl mongo::getSourceFileAndLineNumber(void *,unsigned __int64,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?getSourceFileAndLineNumber@mongo@@YAXPAX_KPAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

1>mongoclientd.lib(stacktrace.obj) : error LNK2019: unresolved external symbol __imp__SymFromAddr@20 referenced in function "void __cdecl mongo::getsymbolAndOffset(void *,unsigned __int64,struct _SYMBOL_INFO *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?getsymbolAndOffset@mongo@@YAXPAX_KPAU_SYMBOL_INFO@@PAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)


On Wednesday, October 24, 2012 12:01:12 PM UTC-7, Mick wrote:

Eric Milkie

unread,
Oct 30, 2012, 3:36:17 PM10/30/12
to mongo...@googlegroups.com
These are some new function calls we've added recently to support stack traces when things go wrong -- sorry we haven't updated the docs.  Add DbgHelp.lib to your link list and that should solve these.
-Eric


--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-dev/-/33mBEaebzYgJ.

Mick

unread,
Oct 30, 2012, 3:53:07 PM10/30/12
to mongo...@googlegroups.com
Thank you, Eric, that fixed those link errors :)
Now another dependent project - that remained unchanged - is giving me

\bson\bsonelement.h(630) : warning C4003: not enough actual parameters for macro 'max'

\bson\bsonelement.h(630) : error C2589: '(' : illegal token on right side of '::'

\bson\bsonelement.h(630) : error C2059: syntax error : '::'

\bson\bsonelement.h(630) : error C2143: syntax error : missing ';' before '{'

\bson\bsonelement.h(631) : warning C4003: not enough actual parameters for macro 'max'

\bson\bsonelement.h(631) : error C2589: '(' : illegal token on right side of '::'

\bson\bsonelement.h(631) : error C2059: syntax error : '::'

\bson\bsonelement.h(633) : warning C4003: not enough actual parameters for macro 'min'

\bson\bsonelement.h(633) : error C2589: '(' : illegal token on right side of '::'

\bson\bsonelement.h(633) : error C2059: syntax error : '::'

\bson\bsonelement.h(633) : error C2143: syntax error : missing ';' before '{'

\bson\bsonelement.h(634) : warning C4003: not enough actual parameters for macro 'min'

\bson\bsonelement.h(634) : error C2589: '(' : illegal token on right side of '::'

\bson\bsonelement.h(634) : error C2059: syntax error : '::'

1>c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(91) : warning C4005: 'AF_IPX' : macro redefinition

1> c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(460) : see previous definition of 'AF_IPX'

The list is long, but you get the jist of it...  Any ideas what might have happened? 
Thanks again.

On Wednesday, October 24, 2012 12:01:12 PM UTC-7, Mick wrote:

Eric Milkie

unread,
Oct 30, 2012, 3:59:33 PM10/30/12
to mongo...@googlegroups.com
This looks like include file conflicts.  Be sure to include only dbclient.h in your code, no other MongoDB headers, and be sure to include it before any other #include lines in your source file.  Also, within dbclient.h we include <windows.h> and define WIN32_LEAN_AND_MEAN as well (this is not ideal, and we will fix this in a later MongoDB version), but for now, you will need to avoid including windows.h in any source file that includes dbclient.h.  I think this is why you are getting ws2def.h errors - you may be including windows.h after dbclient.h?
-Eric


--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-dev/-/4UxAvTObkdQJ.

Mick

unread,
Oct 30, 2012, 6:10:40 PM10/30/12
to mongo...@googlegroups.com
Hi Eric,
I have a solution with 6 projects, of which one communicates with Mongo database.  The other projects call functions from this one dll.  Now dll compiles and links fine, thanks to your suggestions, but I'm getting all these compile errors in 2 of the projects that I did not touch...  I'm confused about the bsonelement.h warnings and errors, because that's part of the mongo source files.  Any ideas why I'm getting those?

Eric Milkie

unread,
Oct 30, 2012, 7:57:42 PM10/30/12
to mongo...@googlegroups.com
The only way you could be getting those compilation errors in MongoDB headers is if you are #including them in your source files. If you don't immediately see where it's coming from, you can try preprocessing one of the files; that should show you the include chain.
-Eric

Mick

unread,
Oct 31, 2012, 2:27:21 PM10/31/12
to mongo...@googlegroups.com
Thank you, Eric, your help is highly appreciated.  However, we're going to stick with the Mongo 2.0.6, the upgrade is taking way too long. 
Might try again at a later date, time permitting...

Andrew Morrow

unread,
Mar 28, 2013, 5:16:39 PM3/28/13
to mongo...@googlegroups.com

Hi Pravish -

Could you please post the exact link errors you are seeing, along with information about which version of the C++ driver you are using? Information on the OS and compiler revision would be very useful as well. It will be easier to diagnose this way rather than referring back to errors from a much earlier thread.

Thanks,
Andrew
 

Pravish Sood

unread,
Mar 29, 2013, 10:31:10 AM3/29/13
to mongo...@googlegroups.com
Hi Andrew,

Thanks for your response. I have attached a txt file containing the linker errors.
I checked out mongo from the github master branch yesterday so it must be the latest development.
I am trying to build a 32 bit version on Win 7 64 bit. I used the msvc11 to build boost_1_53_0 and build the mongo with --extrapath=1_53_0_BoostLibraryPath
I used scons to build the mongoclient.lib. The toolset is msvc11 again. 

Let me know,

Best,

Pravish

From Andrew:
Could you please post the exact link errors you are seeing, along with information about which version of the C++ driver you are using? Information on the OS and compiler revision would be very useful as well. It will be easier to diagnose this way rather than referring back to errors from a much earlier thread.

LinkerErrors.txt

Eric Milkie

unread,
Mar 29, 2013, 10:40:29 AM3/29/13
to mongo...@googlegroups.com
 Hi Pravish,
Can you show the compilation and link command lines you're using?
I suspect you're not using the same calling standard for everything.  When I compare your missing symbols to the ones present in the library, they are mangling differently.  You should be using /MT or /MTd when you compile foo.cpp, to match how scons is compiling the C++ driver files.
-Eric

Pravish Sood

unread,
Mar 29, 2013, 11:40:41 AM3/29/13
to mongo...@googlegroups.com
Hi Eric,

I have attached a file here that shows how I compiled foo.cpp with MSVC and then the compilation errors. 
I think that the mongo scons compiles with /MT option.

Thanks,

Pravish

From Eric:

Can you show the compilation and link command lines you're using?
I suspect you're not using the same calling standard for everything.  When I compare your missing symbols to the ones present in the library, they are mangling differently.  You should be using /MT or /MTd when you compile foo.cpp, to match how scons is compiling the C++ driver files.
-Eric
On Wednesday, October 24, 2012 3:01:12 PM UTC-4, Mick wrote:
CompilationLinkLines.txt

Eric Milkie

unread,
Mar 29, 2013, 12:05:53 PM3/29/13
to mongo...@googlegroups.com
Hi Pravish,
It looks like you are invoking the linker via the compiler, rather than a separate link step.  You may find it easier to invoke the linker separately, to reduce the complexity and make it easier to diagnose errors.
Like I told Mick earlier in this thread, I don't see where you are supplying the mongoclient.lib library to the linker.  Did you put a preprocessor directive somewhere in foo.cpp to ensure that mongoclient.lib is linked in?  If not, the easiest way to link against the C++ driver is to explicitly link it by adding it to the Additional Dependencies field of the Linker Input property page of your project in Visual Studio.  When you look at the Command Line page in that same dialog, if you've done this correctly, you should see mongoclient.lib appear somewhere in there.
-Eric

Pravish Sood

unread,
Mar 29, 2013, 1:36:53 PM3/29/13
to mongo...@googlegroups.com
Hi Eric,

Yes, in the previous message where I shared the compilation and linker lines I had missed supplying the linker with mongoclient.lib. I moved to VS12 ide to follow your suggestion and supplied the mongoclient.lib in the Additional Dependencies. This time however I rebuild the mongoclient.lib in release mode and build the foo.cpp with /MT option. I am now faced with some different linker errors. Please find the attached file for the same. Could you diagnose further?

For boost, I have build both release and debug variants. Could this be conflicting boost versions? I have given the path of boost_1_53_0 while building foo.cpp

Thanks, 

Pravish

From Eric:

Like I told Mick earlier in this thread, I don't see where you are supplying the mongoclient.lib library to the linker.  Did you put a preprocessor directive somewhere in foo.cpp to ensure that mongoclient.lib is linked in?  If not, the easiest way to link against the C++ driver is to explicitly link it by adding it to the Additional Dependencies field of the Linker Input property page of your project in Visual Studio.  When you look at the Command Line page in that same dialog, if you've done this correctly, you should see mongoclient.lib appear somewhere in there.
FurtherLinkerIssues.txt

Eric Milkie

unread,
Mar 29, 2013, 3:20:43 PM3/29/13
to mongo...@googlegroups.com
Some of those link errors will go away if you link against dbghelp.lib (for stacktrace) and ws2_32.lib (for WinSock2).

Unfortunately, the boost errors are from mixing Boost versions.  When mongoclient.lib is built, it uses Boost 1.49 headers included with the mongo source.  But you are now linking against Boost 1.53, and the libraries do not match up with the headers.
If you can, I would recommend using Boost 1.49 in your project, and this will solve the linker errors.

If you must use Boost 1.53, it is possible but complicated to set up. To do so, I rebuilt mongoclient.lib against Boost 1.53 like so:
E:\mongo> scons mongoclient.lib --use-system-boost --64 --d --mute --cpppath="path\to\boost\headers" --libpath="path\to\copied\boost\libraries"

Note that the paths above cannot contain spaces, even if quoted, so you will have to use the 8.3 name if your path contains spaces.  For example, I had to use PROGRA~1 instead of Program Files in my path to boost headers.
Also note that scons will look for libraries named "boost_thread-mt.lib", "boost_filesystem.lib", "boost_system.lib", and "boost_program_options.lib", so you will have to copy the original boost libraries to those names.  For example, I copied libboost_thread-vc100-mt-sgd-1_53.lib to boost_thread-mt.lib.

After building mongoclient.lib in this fashion, and adding dbghelp.lib and ws2_32.lib to your link for your foo project, you should then have no further missing symbols.
-Eric

Pravish Sood

unread,
Mar 30, 2013, 2:09:42 PM3/30/13
to mongo...@googlegroups.com
Hi Eric,

I need to use boost because I am using some advanced boost libraries for my business.
I followed your suggestion and realized that indeed the scons was not finding the boost_1_53 and I used the compilation line u provided in the previous post.
Attached here is the first fraction of output when I run the "scons mongoclient.lib .." command. From here, it looks like boost is now in place. 
However, when I link it with my foo.cpp I am still getting the SAME linker errors, although I got beyond the stacktrace etc. errors with dbghelp.lib. I guess I am missing another important piece here. 

Really appreciate your help so far and looking forwad to a little more.

Thanks

Pravish
buildingMongoclientLib.txt

Eric Milkie

unread,
Apr 1, 2013, 11:47:20 AM4/1/13
to mongo...@googlegroups.com
I would check to see if the symbols that the linker is looking for are in your new mongoclient.lib.  You can list the symbols in mongoclient.lib using the DUMPBIN utility with the /SYMBOLS parameter.

Borat Zagdyew

unread,
Sep 5, 2013, 5:28:01 PM9/5/13
to mongo...@googlegroups.com
Hello Mike!
Can you help me with this?
Use VS10 and 11 (Same Problem)
Boost 1_49

1>------ Neues Erstellen gestartet: Projekt: testtest, Konfiguration: Debug x64 ------
1>  main.cpp
1>c:\users\ivan\documents\visual studio 2010\mongo-cxx-driver-v2.4\src\mongo\db\../bson/bsonobjiterator.h(67): warning C4244: '=': Konvertierung von '__int64' in 'int', möglicher Datenverlust
1>c:\users\ivan\documents\visual studio 2010\mongo-cxx-driver-v2.4\src\mongo\db\../bson/bson-inl.h(121): warning C4267: 'Initialisierung': Konvertierung von 'size_t' nach 'int', Datenverlust möglich
1>c:\users\ivan\documents\visual studio 2010\mongo-cxx-driver-v2.4\src\mongo\db\../bson/bson-inl.h(122): warning C4267: 'Initialisierung': Konvertierung von 'size_t' nach 'int', Datenverlust möglich
1>c:\users\ivan\documents\visual studio 2010\mongo-cxx-driver-v2.4\src\mongo\db\../bson/bson-inl.h(246): warning C4267: 'Argument': Konvertierung von 'size_t' nach 'int', Datenverlust möglich
1>c:\users\ivan\documents\visual studio 2010\mongo-cxx-driver-v2.4\src\mongo\db\../bson/bson-inl.h(570): warning C4267: '=': Konvertierung von 'size_t' nach 'int', Datenverlust möglich
1>c:\users\ivan\documents\visual studio 2010\mongo-cxx-driver-v2.4\src\mongo\db\../bson/bson-inl.h(580): warning C4267: '=': Konvertierung von 'size_t' nach 'int', Datenverlust möglich
1>c:\users\ivan\documents\visual studio 2010\mongo-cxx-driver-v2.4\src\mongo\db\../bson/bson-inl.h(653): warning C4267: '=': Konvertierung von 'size_t' nach 'int', Datenverlust möglich
1>C:\Users\Ivan\Documents\Visual Studio 2010\mongo-cxx-driver-v2.4\src\mongo/util/mongoutils/str.h(77): warning C4267: 'Initialisierung': Konvertierung von 'size_t' nach 'int', Datenverlust möglich
1>C:\Users\Ivan\Documents\Visual Studio 2010\mongo-cxx-driver-v2.4\src\mongo/util/mongoutils/str.h(78): warning C4267: 'Initialisierung': Konvertierung von 'size_t' nach 'int', Datenverlust möglich
1>C:\Users\Ivan\Documents\Visual Studio 2010\mongo-cxx-driver-v2.4\src\mongo/util/net/message.h(279): warning C4267: 'Argument': Konvertierung von 'size_t' nach 'unsigned long', Datenverlust möglich
1>C:\Users\Ivan\Documents\Visual Studio 2010\mongo-cxx-driver-v2.4\src\mongo/db/json.h(362): warning C4244: 'return': Konvertierung von '__int64' in 'int', möglicher Datenverlust
1>C:\Users\Ivan\Documents\Visual Studio 2010\mongo-cxx-driver-v2.4\src\mongo/client/dbclientcursor.h(57): warning C4267: 'return': Konvertierung von 'size_t' nach 'int', Datenverlust möglich
1>C:\Users\Ivan\Documents\Visual Studio 2010\mongo-cxx-driver-v2.4\src\mongo/client/syncclusterconnection.h(149): warning C4267: 'return': Konvertierung von 'size_t' nach 'unsigned int', Datenverlust möglich
1>C:\Users\Ivan\Documents\Visual Studio 2010\mongo-cxx-driver-v2.4\src\mongo/bson/util/builder.h(192): warning C4267: 'Initialisierung': Konvertierung von 'size_t' nach 'const int', Datenverlust möglich
1>          C:\Users\Ivan\Documents\Visual Studio 2010\mongo-cxx-driver-v2.4\src\mongo/bson/util/builder.h(191): Bei der Kompilierung der  Klassen-template der void mongo::_BufBuilder<Allocator>::appendStr(const mongo::StringData &,bool)-Memberfunktion
1>          with
1>          [
1>              Allocator=mongo::TrivialAllocator
1>          ]
1>          c:\users\ivan\documents\visual studio 2010\mongo-cxx-driver-v2.4\src\mongo\db\../bson/bsonobjbuilder.h(94): Siehe Verweis auf die Instanziierung der gerade kompilierten Funktions-template "void mongo::_BufBuilder<Allocator>::appendStr(const mongo::StringData &,bool)".
1>          with
1>          [
1>              Allocator=mongo::TrivialAllocator
1>          ]
1>          C:\Users\Ivan\Documents\Visual Studio 2010\mongo-cxx-driver-v2.4\src\mongo/bson/util/builder.h(329): Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template "mongo::_BufBuilder<Allocator>".
1>          with
1>          [
1>              Allocator=mongo::TrivialAllocator
1>          ]
1>          C:\Users\Ivan\Documents\Visual Studio 2010\mongo-cxx-driver-v2.4\src\mongo/util/hex.h(47): Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template "mongo::StringBuilderImpl<Allocator>".
1>          with
1>          [
1>              Allocator=mongo::TrivialAllocator
1>          ]
1>C:\Users\Ivan\Documents\Visual Studio 2010\mongo-cxx-driver-v2.4\src\mongo/bson/util/builder.h(314): warning C4267: 'Argument': Konvertierung von 'size_t' nach 'int', Datenverlust möglich
1>          C:\Users\Ivan\Documents\Visual Studio 2010\mongo-cxx-driver-v2.4\src\mongo/bson/util/builder.h(314): Bei der Kompilierung der  Klassen-template der void mongo::StringBuilderImpl<Allocator>::append(const mongo::StringData &)-Memberfunktion
1>          with
1>          [
1>              Allocator=mongo::TrivialAllocator
1>          ]
1>          C:\Users\Ivan\Documents\Visual Studio 2010\mongo-cxx-driver-v2.4\src\mongo/bson/util/builder.h(317): Siehe Verweis auf die Instanziierung der gerade kompilierten Funktions-template "void mongo::StringBuilderImpl<Allocator>::append(const mongo::StringData &)".
1>          with
1>          [
1>              Allocator=mongo::TrivialAllocator
1>          ]
1>LINK : fatal error LNK1104: Datei "libboost_thread-vc110-mt-sgd-1_49.lib" kann nicht geöffnet werden.
========== Alles neu erstellen: 0 erfolgreich, 1 fehlerhaft, 0 übersprungen ==========



Eric Milkie

unread,
Sep 6, 2013, 7:17:29 AM9/6/13
to mongo...@googlegroups.com
I'm not Mike, but perhaps I can help.
You are attempting to link against "libboost_thread-vc110-mt-sgd-1_49.lib" but the linker cannot find that file. Do you have it somewhere in the path specified to the linker by /LIBPATH? Also check the other causes listed by this web page: http://msdn.microsoft.com/en-us/library/ts7eyw4s.aspx

Reply all
Reply to author
Forward
0 new messages