 | Binaries are available for most platforms. Most users won't need to compile mongo themselves; in addition every prebuilt binary has been regression tested. See the Downloads page for these prebuilt binaries. |
v2.1.1+
MongoDB can be compiled for Windows (32 and 64 bit) using Visual C++. SCons is the make mechanism, although a solution file is also included in the project for convenience when using the Visual Studio IDE. (These instructions don't work using Visual Studio Express, which must be uninstalled to get Visual Studio Professional/Ultimate to work properly; VSE can only do 32 bit builds.)
These instructions are for mongo versions 2.1.1 and later.
Get the MongoDB Source Code
Download the source code from Downloads.
Or install Git. Then:
- git clone git://github.com/mongodb/mongo.git (more info)
- git tag -l to see tagged version numbers
- Switch to a stable branch (unless doing development) -- an even second number indicates "stable". For example:
Building MongoDB from the IDE
Open the db\db_10.sln solution file.
Note: a separate project file exists for the mongo shell. Currently the C++ client libraries must be built from scons (this obviously needs to be fixed...)
Building with SCons
- Install SCons:
- First install Python: http://www.python.org/download/releases/2.7.2/.
- Note Make sure to install the 32 bit version of python and not the 64 bit as the scons binaries below are 32 bit.
- It is recommended you install pywin32 if you want to do parallel builds (scons -j). http://sourceforge.net/projects/pywin32/files/pywin32/Build216/pywin32-216.win32-py2.7.exe/download
- Then install SCons itself: http://sourceforge.net/projects/scons/files/scons/2.1.0/scons-2.1.0.win32.exe/download.
- Add the python scripts directory (e.g., C:\Python27\Scripts) to your PATH.
- Build:
scons scons --release mongoclient.lib scons --release core
Add --64 or --32 to get the 64 and 32-bit versions, respectively. Replace --release with --dd to build a debug build.
Troubleshooting
 | If you are using scons, check the file config.log which is generated. |
If scons does not automatically find Visual Studio, try using the Visual Studio Command Prompt, which will set your path for you. Alternatively, set your path manually by running the VS2010 vcvars*.bat files. Location may vary with install but usually it is something like:
- C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\vsvars32.bat
- C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat
Older versions
The following instructions are for versions of mongo prior to 2.1.1.
There are several dependencies exist which are listed below; you may find it easier to simply download a pre-built binary.
Get the MongoDB Source Code
Download the source code from Downloads.
Or install Git. Then:
- git clone git://github.com/mongodb/mongo.git (more info)
- git tag -l to see tagged version numbers
- Switch to a stable branch (unless doing development) -- an even second number indicates "stable". (Although with sharding you will want the latest if the latest is less than 1.6.0.) For example:
Get Boost Libraries
- Click here for a prebuilt boost library for Visual Studio. 7zip format. This file has what you need to build MongoDB, but not some other boost libs, so it's partial. Uncompress this to the c:\boost directory. Your actual files are in c:\boost\boost
- See the Boost and Windows page for other options. Use v1.42 or higher with VS2010.
Get SpiderMonkey
- Download prebuilt libraries and headers here for VS2010. Place these files in ..\js\ relative to your mongo project directory.
- Or (more work) build SpiderMonkey js.lib yourself – details here.
Building MongoDB from the IDE
Open the db\db_10.sln solution file.
Note: a separate project file exists for the mongo shell. Currently the C++ client libraries must be built from scons (this obviously needs to be fixed...)
Install SCons
If building with scons, install SCons:
The SConstruct file from the MongoDB project is the preferred way to perform production builds. Run scons in the mongo project directory to build.
If scons does not automatically find Visual Studio, preset your path for it by running the VS2010 vcvars*.bat files. Location may vary with install but usually it is something like:
- C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\vsvars32.bat
- C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat
To build:
scons scons mongoclient.lib scons all scons . scons --64 scons --dd scons -jX
Troubleshooting
 | If you are using scons, check the file config.log which is generated. |
- Can't find jstypes.h when compiling.
- Can't find / run cl.exe when building with scons.
- Be sure to use Visual Studio Command Prompt so that your path is set correctly.
- LINK : fatal error LNK1104: cannot open file js64d.lib js64r.lib js32d.lib js32r.lib
- Get the prebuilt spidermonkey libraries -- or copy your self-built js.lib to the above name.
- You can also see this if you're using the wrong compiler; this is the result if you try to use Visual Studio Express instead of Visual Studio Professional/Ultimate, which is a different product.
PLEASE POST QUESTIONS IN THE USER GROUPS FORUM. Post non-question comments and helpful hints here.
blog comments powered by Disqus