Building 4.2.12 server on windows failing

Hi Team,

I am trying to build the tag version 4.2.12 on windows machine using cygwin. Followed the steps given in respective build.md file. Getting below error.

$ python buildscripts/scons.py mongod
scons: Reading SConscript files ...
scons: running with args C:\Softwares\python-3.7.9\python.exe buildscripts/scons.py mongod
scons version: 3.1.2
python version: 3 7 9 'final' 0
CC is cl
cl was not found in $PATH
cl resolves to C:\Softwares\mongo-4.2.12\mongo\cl
CXX is $CC
$CC was not found in $PATH
$CC resolves to C:\Softwares\mongo-4.2.12\mongo\$CC
Checking whether the C compiler works... (cached) yes
Checking whether the C++ compiler works... (cached) yes
Checking that the C++ compiler can link a C++ program... (cached) yes
Checking if C++ compiler "$CC" is MSVC... (cached) yes
Checking if C compiler "cl" is MSVC... (cached) yes
Detected a x86_64 processor
Checking if target OS windows is supported by the toolchain... (cached) yes
Checking if C compiler is Microsoft Visual Studio 2017 15.9 or newer...(cached) yes
Checking if C++ compiler is Microsoft Visual Studio 2017 15.9 or newer...(cached) yes
Checking if we are using libstdc++... (cached) no
Checking for C++17... (cached) yes
Checking for memset_s... (cached) no
Checking for C function strnlen()... (cached) no
Checking Windows SDK is 8.1 or newer... (cached) yes
Checking if we are on a POSIX system... (cached) no
Checking for storage class thread_local (cached) yes
Checking for C++14 std::enable_if_t support...(cached) yes
Checking for C++14 std::make_unique support... (cached) yes
Using SSL Provider: windows
Checking for C++ header file execinfo.h... (cached) no
Checking for C library pcap... (cached) no
Checking for C library wpcap... (cached) no
Checking if std::atomic<int64_t> works... (cached) yes
Checking if std::atomic<uint64_t> works... (cached) yes
Checking if std::atomic<int32_t> works... (cached) yes
Checking if std::atomic<uint32_t> works... (cached) yes
Checking for extended alignment 64 for concurrency types... (cached) yes
Checking for mongoc_get_major_version() in C library mongoc-1.0... (cached) no
Checking for C function fallocate()... (cached) no
Checking for C function sync_file_range()... (cached) no
Checking for C header file x86intrin.h... (cached) no
Checking for C header file arm_neon.h... (cached) no
scons: done reading SConscript files.
scons: Building targets ...
scons: *** Do not know how to make File target `mongod' (C:\Softwares\mongo-4.2.12\mongo\mongod).  Stop.

Please try this again but from within a cmd.exe shell, not a cygwin shell. We don’t support or test running the windows targeted build inside cygwin, nor do we support targeting cygwin at all. I suspect though that SCons does internally have some awareness of cygwin, and is therefore misconfiguring the build. The fact that it is looking to build mongod rather than mongod.exe is something of a hint along these lines.

Hi Andrew,

I tried the same steps with cmd.exe shell . Getting same error.

Thanks-Annapoorna

Hi Andrew,

I tried with target core, instead of giving mongod/mongos/mongo , then it started building. And after successful build, I had mongod.exe/mongos.exe/mongo.exe generated. Anything wrong syntax I have given when specific mongod is passed as argument to scons.py?

Regards
Annapoorna

I’d overlooked in your original build invocation that the target you passed to SCons was mongod. SCons accepts two types of targets on the command line: alias targets and file targets. In the v4.2 codebase, the server binaries are installed to the root of the source tree. So when you say scons mongod you are asking SCons to build the file mongod. But on windows, executables come with the .exe extension, so on that platform you need to invoke scons mongod.exe instead, since you are asking for the exact file to be built. The other sort of target, alias targets, are a synthetic name for a group of other targets. These, unlike file targets, do not vary by platform. The core target that you built is such an alias, and so it is able to build either mongod or mongod.exe as needed by the local environment. That is why that build worked for you and the other didn’t.

Also, please note that in MongoDB v4.4 and later, the set of aliases has been reworked. If you move to v4.4, you will find that the target you want is install-core, and the files will not be placed in the root of the source tree, but will be installed by default to build/install. The path to which they are installed can be customized with the DESTDIR and PREFIX variables.

Finally, I still recommend using cmd.exe rather than trying to build within a cygwin shell.

1 Like

Thanks Andrew for the detailed explanation. Thats very informative.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.