Do I need to add in boost source manually when compiling sample app with Visual Studio 2010?

34 views
Skip to first unread message

Therefore

unread,
Oct 6, 2012, 6:49:09 PM10/6/12
to mongod...@googlegroups.com
Windows 7 64 SP1
MongoDB 2.2.0
MS VS 2010
C++ driver

I've upgraded to 2.2.0.

The MS VS project simple_client_demo in examples has a Boost filter in the Solution Explorer that lists 15 boost .cpps from codecvt_error_category.cpp to windows_file_codecvt.cpp.

I presume this is because you now include boost in the MongoDB release. Am I supposed to add these files manually for every new project I work on?

Mark

Tad Marshall

unread,
Oct 7, 2012, 6:43:44 AM10/7/12
to mongod...@googlegroups.com
Hi Mark,

Yes, these Boost files and their settings are needed by the MongoDB client components.

If you set these up using the GUI in Visual Studio, be sure to check the Properties for the source files to make sure that you copy the handful of special cases for some files.  In MongoDB itself, we use both ..\..\third_party\boost\libs\program_options\src\utf8_codecvt_facet.cpp and ..\..\third_party\boost\libs\filesystem\v3\src\utf8_codecvt_facet.cpp, so we have to change the output filename on one of them to prevent filename collisions on the .obj files.  We set the output filename for ..\..\third_party\boost\libs\filesystem\v3\src\utf8_codecvt_facet.cpp to $(IntDir)filesystem_utf8_codecvt_facet.obj to do this.  simple_client_demo does not use Boost::program_options so it doesn't need this, but we did it anyway for consistency.  simple_client_demo does use the thread files thread.cpp, tss_dll.cpp and tss_pe.cpp and we add an additional preprocessor symbol BOOST_THREAD_BUILD_LIB for those three files.

Two alternatives to copying all of this stuff by hand in the GUI are:
1)  Start with a copy of simple_client_demo.vcxproj and simple_client_demo.vcxproj.filters and change them to turn the copy into your project;
2)  Copy text directly from simple_client_demo.vcxproj and simple_client_demo.vcxproj.filters into your project and filters files.  The vcxproj files are XML files that aren't too hard to figure out and you might find it faster to use a text editor to copy and paste what you need rather than do a lot of mouse clicking to do it in the GUI.

The filter part is just for convenience and organization; it's not actually required, but it makes it easier to separate the different bits in the GUI.  You can do a combination of GUI changes and text editor changes to get the vcxproj file(s) into the form you need; you just need to be careful in the text editor to keep the XML well-formed.

Tad

Therefore

unread,
Oct 7, 2012, 1:13:12 PM10/7/12
to mongod...@googlegroups.com
Hi Tad,

Thank you for the detailed response.

I had perused the .vcxproj & .vcxproj.filters and caught the special source files properties for the thread files (well, caught after getting compile errors). I've set up a standard .vcxproj & .vcxproj.filter. After creating a new project, I get the project GUID from its .vcxproj and then copy over the standard files, editing .vcxproj to add in the new GUID and the project name. Then I add the project name to .vcxproj.filters. Along with my standard property sheet (after modifying from what I found in simple_client_demo), I'm able to setup a new project quickly. And I'll need to do this for all my existing projects.

I did miss setting the output file for C:\mongodb\src\third_party\boost\libs\filesystem\v3\src\utf8_codecvt_facet.cpp but, as you said, it wasn't necessary for the demo. My question: Will I ever need to use both the v3 version and the third_party\boost\libs\program_options\src\utf8_codecvt_facet.cpp version in my applications? Or is this used only for building mongoDB and I won't need to add the program_options version into my applications? In general, are these 15 boost files all that I will ever need to compile? Excluding those I add for my own use.

Oh, and thanks for your work getting the shell to handle Unicode fully in the shell. That was why I needed to upgrade. I'm having a hard enough time getting C++/Windows to work with UTF-8, that I needed the shell to see the results. My application will be fully Unicode compliant, so I'm on a learning curve here.

Mark

Tad Marshall

unread,
Oct 7, 2012, 1:38:11 PM10/7/12
to mongod...@googlegroups.com
Hi Mark,

All of the MongoDB programs that accept arguments on the command line (I think that's all of them) use Boost::program_options to do the command line parsing.  It's pretty easy to use once you master the syntax and it gives us some uniformity between the parsers in the different programs.  If you don't use program_options in your program, and don't use some other commonly named source file then you won't need to worry about filename collisions.  Actually, Visual Studio already "deals with this" for us by appending a "1" to the object file name, but I made it explicit so that I can tell which .obj file is which more easily.

The set of Boost files listed under "Boost" in the Visual Studio project are all you need for client code in this version, but I can't promise what might be used in a future version.

I'm glad that the Unicode in the shell is helpful to you.  If you haven't done it already, you might want to add EnableHexNumpad in the registry (see http://en.wikipedia.org/wiki/Unicode_input#In_Microsoft_Windows ) to let you input Unicode easily regardless of your keyboard setting.  You can also add non-US keyboards and switch between them; the US International keyboard (see http://support.microsoft.com/kb/306560 ) was helpful to me in testing in Windows.

Tad
Reply all
Reply to author
Forward
0 new messages