use mongoclient.lib in a multi-threaded dll

122 views
Skip to first unread message

Mick

unread,
Nov 5, 2012, 2:47:28 PM11/5/12
to mongo...@googlegroups.com
If I include mongoclient.lib in my project, it only builds successfully if the flag is set to /MTd.  Is there any option to build mongoclient.lib (through scons) so that my project builds successfully as an /MDd?
Thanks.

Eric Milkie

unread,
Nov 6, 2012, 9:50:03 AM11/6/12
to mongo...@googlegroups.com
There is no option to build the client library that way, but it should work if you just change the /MTd in SConstruct to be /MDd and rebuild everything.

Mick

unread,
Nov 6, 2012, 12:14:27 PM11/6/12
to mongo...@googlegroups.com
I tried that and now my project won't link, it comes up with:

mongoclientd.lib(connpool.obj) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'

I tried to change the Target machine to "not set" in project properties->configuration properties->linker->advanced and that didn't make any difference...

Any other suggestions?


On Monday, November 5, 2012 11:47:28 AM UTC-8, Mick wrote:

Eric Milkie

unread,
Nov 6, 2012, 1:28:37 PM11/6/12
to mongo...@googlegroups.com
When you compile the library, you must explicitly pass --32 or --64 to scons as appropriate for which architecture you want.
-Eric

Mick

unread,
Nov 6, 2012, 2:43:38 PM11/6/12
to mongo...@googlegroups.com
Thanks Eric,
It looks like scons is ignoring the flag, I built the library using --32 and I'm still getting the error :(
Any other suggestions? 

On Monday, November 5, 2012 11:47:28 AM UTC-8, Mick wrote:

Eric Milkie

unread,
Nov 6, 2012, 3:02:16 PM11/6/12
to mongo...@googlegroups.com
You are still getting the architecture error for connpool.obj, that is?
What does the command line look like when it builds the object file?
You can tell scons to bring it up to date by itself by passing the path to the obj file:

scons.bat --32 build\32\<etc..>\connpool.obj

Mick

unread,
Nov 6, 2012, 3:35:00 PM11/6/12
to mongo...@googlegroups.com
Sorry, I guess I didn't provide all the details... 
mongoclient.lib builds successfully when I change the MT flag to MD in SConstruct, but then I add the lib to my C++ projects and try to build them as multi-threaded dlls with the /MDd flag in VC++ 2008, and it comes up with

mongoclientd.lib(connpool.obj) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'

in one and

mongoclientd.lib(oid.obj) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'

in the second one.  The second project is dependent on the first.


On Monday, November 5, 2012 11:47:28 AM UTC-8, Mick wrote:

Eric Milkie

unread,
Nov 6, 2012, 3:44:47 PM11/6/12
to mongo...@googlegroups.com
It still looks like you compiled connpool.obj and oid.obj in 64-bit mode. Can you show the compiler command line scons is using to build those?

Mick

unread,
Nov 6, 2012, 3:57:48 PM11/6/12
to mongo...@googlegroups.com
Couldn't catch the oid.obj, but the the connpool:
 
cl /Foclient\connpool.obj /c client\connpool.cpp /TP /nologo /EHsc /W3 /wd4355 /
wd4800 /wd4267 /wd4244 /RTC1 /MDd /Z7 /TP /errorReport:none /Fd"mongod.pdb" /D_S
CONS /DMONGO_EXPOSE_MACROS /D_UNICODE /DUNICODE /D_CONSOLE /D_CRT_SECURE_NO_WARN
INGS /DPSAPI_VERSION=1 /DNOEXECINFO /Ithird_party\pcre-7.4 /I. "/IC:\Program Fil
es (x86)\Boost\boost_1_47" "/IC:\Program Files\Microsoft SDKs\Windows\v6.1\Inclu
de" /IC:\Mongo2.0.6\mongodb32\winpcap\Include
connpool.cpp
client\connpool.cpp(153) : warning C4101: 'e' : unreferenced local variable
client\connpool.cpp(167) : warning C4101: 'e' : unreferenced local variable
client\connpool.cpp(187) : warning C4101: 'e' : unreferenced local variable
Reply all
Reply to author
Forward
0 new messages