Add-Ons & Services

Poco/MongoDB 64 Bit Issue on Windows 7 Pro

Please post support and help requests here.
Posts: 2
Joined: 18 Feb 2014, 21:28

Poco/MongoDB 64 Bit Issue on Windows 7 Pro

Postby ccc123 » 18 Feb 2014, 22:05

I'm having one crazy hard time compiling the Mongo C++ driver for Windows.
The word "crazy" is key here as I am almost ready to go insane (one of my only posts to a coding forum in my lifetime).

I first tried here: http://docs.mongodb.org/ecosystem/drivers/cpp/
And could usually get 99.99999% of the way there I would encounter some cryptic linking error.
But like reaching the speed of light I couldn't reach the 100% mark to write a single line of functional Mongo C++ code on Windows.

See this comment posted on Nov 4, 2013:
http://stackoverflow.com/questions/1977 ... of-mongodb
"What is the error? The C++ driver compilation process on Windows is NOTORIOUSLY horrible"

After some time I gave up on this approach and worked on building the Poco libraries, the latest of which includes a MongoDB module (I now have other reasons for wanting to use Poco besides just Mongo but the Mongo component is critical in my application).
I had read a comment about another user having similar problems as myself, who initially gave up, and was able to build the Poco/Mongo C++ driver on Windows.

Here, I COULD build the 32 bit version and run any of the C++ samples demonstrating the use of MongoDB via the awesome Poco toolset.
However, I need more than 32 bits worth of RAM to make my application feasible.

When I try to build the 64 bit version (static or shared, using VS 2010 Pro or not) of Poco/Mongo, I can (apparently) build all dependent libraries without issue. When I compile the 64 bit Mongo demos in Poco, my hopes are additionally high. Then when I run a sample such as "bin64/SQLToMongo.exe" or "bin64/TestSuite.exe" under the MongoDB module, my hopes advance even further (especially since the 32 bit version worked just fine). When I can confirm through RoboMongo that the connections are made using these compiled apps I am ready to think my Twilight Zone episode has finished, and I can finally write a single line of C++ code that can talk to Mongo on Windows in 64 bit mode.

NOT SO however.

When I run these sample Poco/Mongo codes (64 bit on Windows), just the demos themselves, they can connect but cannot perform any operation successfully within Mongo (as verified by RoboMongo). Yet if I flip to 32 bit mode and compile, presto, the same code works.

For example, in "SQLToMongo.cpp", sample1 executes until reaching this line of code:
std::string lastError = db.getLastError(connection);
And at this point the application hangs, with no results whatsoever showing up.
If I put another line of code in front of this:
int count = (int)db.count( connection, "team");
Also the application hangs (with any call to db.whatever) in 64 bit mode.

As another example, in "MongoDBTest::testInsertRequest()", code that I have not modified whatsoever from the demo, seems to have no issues and completes in 64 bit mode. I can see in the Mongo log file the connect and disconnect events. But no results show up in the MongoDB after this test insert (as verified by RoboMongo). Once again, perfect execution in 32 bit mode, but that doesn't help me given my requirements.

I seriously have no idea whatsoever to even look for at this point, so any advice for what I should do next would be greatly appreciated, other than give up, use 32 bit mode, or try another database or operating system, etc. At this point I am grasping at straws like do I need to use a super extra special flavor of "mongod.exe" etc. I have Visual Studio 2010 Pro and Windows 7 Pro.

Sample code and the build attempts are attempted directly from the Poco/Mongo library from "poco-poco-1.5.2-release.zip".

Thanks in advance for any insights.

Posts: 113
Joined: 11 Aug 2008, 22:47
Location: Belgium

Re: Poco/MongoDB 64 Bit Issue on Windows 7 Pro

Postby fbraem » 19 Feb 2014, 10:53

I'll start a search for a Windows 7 64 bit system and try to debug this version to see what's the problem ... What stacktrace do you see when you break the execution of the test program?
Zumuta!, that's the way to do IT!

Posts: 1183
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: Poco/MongoDB 64 Bit Issue on Windows 7 Pro

Postby guenter » 19 Feb 2014, 11:09

The problem is using std::size_t for data items which are serialized using Poco::BinaryWriter and deserialized using Poco::BinaryReader. On a Visual C++ 64-bit build, std::size_t is 64-bits while on a 32-bit system it's 32-bits. Use Poco::UInt32 instead of std::size_t for those variables.

Posts: 113
Joined: 11 Aug 2008, 22:47
Location: Belgium

Re: Poco/MongoDB 64 Bit Issue on Windows 7 Pro

Postby fbraem » 19 Feb 2014, 11:54

Can you change std::size_t in Poco/MongoDB/MessageHeader.h on line 101 into Poco::Int32 and see if this helps?

Zumuta!, that's the way to do IT!

Posts: 2
Joined: 18 Feb 2014, 21:28

Re: Poco/MongoDB 64 Bit Issue on Windows 7 Pro

Postby ccc123 » 19 Feb 2014, 18:28

Thank you both tremendously.

The fix on line 101 in "MessageHeader.h" from std::size_t to Poco::Int32 did the trick.
At least I am finally up and running with the C++ driver on Poco/Mongo in Windows, 64 bit mode.

Both the 32 and 64 bit build produce identical results now.

The MongoDB TestSuite.exe application now runs without any issues (both 32 and 64 bit).

SQLToMongo.exe only fails in sample5 (both 32 and 64 bit) now. If I comment this line of code this works as well (without the sort):

// cursor.query().selector().addNewDocument("$orderby").add("lastname", 0);

Although I am curious as to why the sort doesn't work, I can at least make progress on my project.

Again, thank you very much.

(And Franky, glad to see you are now in the team.players Mongo collection after MongoDBTest::testInsertRequest() inserted your name correctly in 64 bit Windows!)

Return to “Support”

Who is online

Users browsing this forum: No registered users and 1 guest