Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>EDIT</strong>: This posting gets a lot of traffic, but describes how to build the now-officially-out-of-date "Legacy C++" Driver. The Legacy C++ driver has been obsoleted by the new C++11 driver. The new C++11 driver should be the first choice when writing a client application in C++ that will communicate with MongoDB. Information on how to build the new C++11 driver is available here: </p> <p><a href="https://github.com/mongodb/mongo-cxx-driver/wiki/Quickstart-Guide-(New-Driver)" rel="nofollow">https://github.com/mongodb/mongo-cxx-driver/wiki/Quickstart-Guide-(New-Driver)</a></p> <p><strong>EDIT</strong>: Please note that this answer is obsolete. Tyler's answer below is the correct answer for all modern users of the C++ driver.</p> <p>I recommend against trying to use the C++ driver tarball from the 2.5 release (or, for that matter, in the 2.4 release) to build the driver library.</p> <p>The best way to build the C++ driver is from the complete mongodb source archive. There are several reasons for this, but the most important is that the tarball build offers only a very minimal build system. As you noticed, it has no 'install' targets. Another limitation is that the tarball build cannot produce a shared object, while the full sources can.</p> <p>Here are some basic instructions on building the C++ driver from the primary mongodb sources:</p> <ul> <li>Clone the mongodb sources from <a href="https://github.com/mongodb/mongo" rel="nofollow">https://github.com/mongodb/mongo</a></li> <li>Run <code>scons --prefix=&lt;path-to-install&gt; --full --use-system-all install-mongoclient</code></li> <li>If you want a shared library (supported in latest 2.4, and latest 2.5), add <code>--sharedclient</code> to the line above.</li> <li>If you want a debug build of the library, pass either <code>--dd</code> (2.4), or <code>--dbg=on</code> (2.5 tip of trunk).</li> </ul> <p>The <code>--use-system-all</code> flag is very important: using it inhibits building against the vendored in versions of things like boost and pcre that come with the primary mongodb sources. You do not want your library to build against those libraries, since the resulting library will not be appropriate to mix with applications built against the system versions of those libraries. This is particularly important when building with <code>--sharedclient</code>.</p> <p>One challenge with the above is that when building with <code>--use-system-all</code>, the build system checks for the presence of various libraries on the system. Some of these libraries, like v8, may not be available. On 2.4, you must either install an applicable version of the library, or edit the SConstruct to inhibit the CheckLib calls that look for the library. On 2.5, this is not an issue as missing libraries only cause the build to fail if you try to build a target that depends on the missing library. Since building the C++ client driver only depends on a small number of libraries (like boost), it is much easier to get working.</p> <p>I also recommend building with a test <code>--prefix</code> argument first to ensure that the installation actions are as you intend.</p> <p>Hope this helps.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload