Build Mongod from source code

Hi,

I have been trying to run Scons.py and continuosly getting the VC version not installed. I have set path env variable for cl and c compilers.

$path has following environements paths added
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.30.30705\bin\Hostx64\x86\cl.exe

XXX\Installed\CodeBlocks\MinGW\bin

Script execution trace is as follows…

scons: running with args XXX\Softwares\Installed\Python\python.exe XXX\MongoD upgrade\mongo-r4.4.11\mongo-r4.4.11\buildscripts\scons.py install-mongod --disable-warnings-as-errors MONGO_VERSION=4.4.11
scons version: 3.1.2
python version: 3 10 2 'final' 0

scons: warning: VC version 14.2 not installed.  C/C++ compilers are most likely not set correctly.
 Installed versions are: []
File "XXX\UTILITY\IPS\JIRA-TICKETS\MongoD upgrade\mongo-r4.4.11\mongo-r4.4.11\SConstruct", line 1150, in <module>

scons: warning: VC version 14.2 not installed.  C/C++ compilers are most likely not set correctly.
 Installed versions are: []
File "XXX\UTILITY\IPS\JIRA-TICKETS\MongoD upgrade\mongo-r4.4.11\mongo-r4.4.11\SConstruct", line 1150, in <module>

scons: warning: VC version 14.2 not installed.  C/C++ compilers are most likely not set correctly.
 Installed versions are: []
File "C:\Products\WMS\Code\UTILITY\IPS\JIRA-TICKETS\WMSNG-8260 MongoD upgrade\mongo-r4.4.11\mongo-r4.4.11\SConstruct", line 1150, in <module>
CC is cl
cl was not found in $PATH
cl resolves to XXX\UTILITY\IPS\JIRA-TICKETS\MongoD upgrade\mongo-r4.4.11\mongo-r4.4.11\cl
CXX is $CC
$CC was not found in $PATH
$CC resolves to XXX\UTILITY\IPS\JIRA-TICKETS\MongoD upgrade\mongo-r4.4.11\mongo-r4.4.11\$CC
Checking whether the C compiler works... no
C compiler cl doesn't work
See XXX\UTILITY\IPS\JIRA-TICKETS\ MongoD upgrade\mongo-r4.4.11\mongo-r4.4.11\build\scons\config.log for details

Please let me know,what am i making mistake here and wht required to be done here…?

Have a look at this thread.You may get additional info
Does cl.exe run from bin dir?
May be path changes not saved properly.Did you update user or system variable?

How to install mongodb from source code

1 Like

I think the path should point to the directory containing cl.exe (not the file entirely)

Try setting your path to something like: C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.30.30705\bin\Hostx64\x86\

Hi @Pavan_Kumar9 -

Currently, no stable branches of MongoDB support builds with VS 2022, and the version of SCons we have vendored on those branches is entirely unaware of VS 2022, so it won’t find it anyway.

For now, you will need to install VS 2019 to build any stable MongoDB release from source. However, on the master branch, we just recently upgraded the required version of VS to be VS 2022, and updated our internal version of SCons to be aware of it.

If you are interested in the changes required in order to build with VS 2022, you can review the commits that introduced support here:

Note that with these changes in place, you don’t need to run a dressed shell or worry about having the right cl.exe in the PATH: SCons will find it for you.

Since we have never tested building stable releases (e.g. MongoDB v5.x or older) with VS 2022, compilation of those branches may or may not succeed if you adopted the above changes, and the resulting binaries may or may not work.

The next Major Release, MongoDB 6.0, will be compatible with and require VS 2022.

Thanks,
Andrew