Error building mongodb from sources

build mongodb from source
mongodb open source
mongodb download
install mongodb
mongodb repository
mongodb/mongodb
mongodb arm
mongodb local

I'm trying to build mongodb from sources and getting a number of errors.

Here's the pastebin of the whole output: http://pastebin.com/pyZLTkz4

The first error is

endian.h does not define __BYTE_ORDER nor BYTE_ORDER. Cannot determine endianness.

And all other errors are like

error: template with C linkage
error: template specialization with C linkage

My configuration is:

  1. Debian 8 64 bit
  2. scons version: 2.3.1
  3. python version: 2 7 9
  4. gcc version: gcc (Debian 4.9.2-10) 4.9.2

Installed dependencies with

sudo apt-get build-dep mongodb

I have tried to build it under CentOS 7 and had the same result.


This is happening while building the embedded SpiderMonkey engine ("mozjs" - Mozilla JavaScript, version 38).

As you're using a VERBOSE=1 build in SCONS, you're seeing that an include directory is added via the -I switch to compile with -Ibuild/opt/third_party/mozjs-38/extract/mfbt. Because of the very aggressive behavior of -I, this means any include files in that directory will pre-empt any system include files of the same name.

(For why -I acts this way, see "Why do projects use the -I include switch given the dangers?". I'll add for Google crawlers that builds circa 2018 use SpiderMonkey 45, so the directory is -Ibuild/opt/third_party/mozjs-45/extract/mfbt)

So what's happening is that the mfbt/Endian.h file (which brings in a bunch of high-level C++ definitions) is overriding your system's low-level /usr/include/endian.h file, which is wreaking havoc when anyone tries to #include <endian.h> to get the system definitions.

The question you likely have is why is it only happening to you...and a few others.

I'm going to guess the reason is probably the same as in my case, which led me to this question: your MongoDB source files are on a filesystem that is retrieving them case-insensitively. So perhaps you are running a Debian Linux VM but have your files on a Windows host.

Most people building on Linux are using fully case-sensitive filesystems, that wouldn't have an Endian.h considered as a candidate to override their system's endian.h. So their builds succeed.


If you are running a version of Windows 10 since the April 2018 update, and have the Windows Subsystem for Linux enabled, then you can set specific Windows directories to be case-sensitive, e.g.

fsutil.exe file SetCaseSensitiveInfo C:\Projects\mongo\src\third_party\mozjs-45\extract\mfbt enable

Unfortunately, it's something you have to set up on each individual folder...you can't do it for entire subtrees. :-(

error building mongodb from source, This might help you out. https://groups.google.com/forum/#!msg/mongodb-user/​noH__CkufmU/1MjlHo5cCAAJ. When you download the zip file from github that  I'm going to guess the reason is probably the same as in my case, which led me to this question: your MongoDB source files are on a filesystem that is retrieving them case-insensitively. So perhaps you are running a Debian Linux VM but have your files on a Windows host.


About first error

The sys/param.h header normally defines the symbols __BYTE_ORDER, __BIG_ENDIAN, __LITTLE_ENDIAN, and __PDP_ENDIAN. You can test endianness by doing something like:

The sys/param.h header normally defines the symbols __BYTE_ORDER, __BIG_ENDIAN, __LITTLE_ENDIAN, and __PDP_ENDIAN. You can test endianness by doing something like:

   #include <sys/param.h>

   #ifdef __BYTE_ORDER
   # if __BYTE_ORDER == __LITTLE_ENDIAN
   #  define I_AM_LITTLE_ENDIAN
   # else
   #  if __BYTE_ORDER == __BIG_ENDIAN
   #   define I_AM_BIG_ENDIAN
   #  else
       Error: unknown byte order!
   #  endif
   # endif
   #endif /* __BYTE_ORDER */

If __BYTE_ORDER is not defined, you may want to test for the existance of BYTE_ORDER, BIG_ENDIAN and LITTLE_ENDIAN. Linux defines these as synonym of the versions with underscores, apparantly in attempt to be compatible with BSD Unix.

If that is not defined, you might try things like:

   #if defined (i386) || defined (__i386__) || defined (_M_IX86) || \
        defined (vax) || defined (__alpha)
   # define I_AM_LITTLE_ENDIAN
   #endif

Read more

c++ - Error building mongodb from sources, This is happening while building the embedded SpiderMonkey engine ("mozjs" - Mozilla JavaScript, version 38). As you're using a VERBOSE=1 build in SCONS  We would like to show you a description here but the site won’t allow us.


A couple of options:

A. You're missing the glibc development headers.

Try installing libc6-dev (debian) or glibc-headers (redhat)

B. You have a non-standard endian.h floating around on your include path

You could try running:

g++ -M -Wnon-virtual-dtor -Woverloaded-virtual -std=c++11 -Wno-non-virtual-dtor -fno-omit-frame-pointer -fPIC -fno-strict-aliasing -ggdb -pthread -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -O2 -Wno-unused-local-typedefs -Wno-unused-function -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-missing-braces -fno-builtin-memcmp -include js-confdefs.h -Wno-invalid-offsetof -DAB_CD -DIMPL_MFBT -DJS_USE_CUSTOM_ALLOCATOR -DNO_NSPR_10_SUPPORT -DSTATIC_JS_API=1 -DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1 -DPCRE_STATIC -DBOOST_THREAD_VERSION=4 -DBOOST_THREAD_DONT_PROVIDE_VARIADIC_THREAD -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS -DBOOST_THREAD_HAS_NO_EINTR_BUG -Isrc -Ibuild/opt -Isrc -Ibuild/opt/third_party/mozjs-38/extract/js/src -Isrc/third_party/mozjs-38/extract/js/src -Ibuild/opt/third_party/mozjs-38/extract/mfbt -Isrc/third_party/mozjs-38/extract/mfbt -Ibuild/opt/third_party/mozjs-38/extract/intl/icu/source/common -Isrc/third_party/mozjs-38/extract/intl/icu/source/common -Ibuild/opt/third_party/mozjs-38/include -Isrc/third_party/mozjs-38/include -Ibuild/opt/third_party/mozjs-38/mongo_sources -Isrc/third_party/mozjs-38/mongo_sources -Ibuild/opt/third_party/mozjs-38/platform/x86_64/linux/build -Isrc/third_party/mozjs-38/platform/x86_64/linux/build -Ibuild/opt/third_party/mozjs-38/platform/x86_64/linux/include -Isrc/third_party/mozjs-38/platform/x86_64/linux/include -Isrc/third_party/zlib-1.2.8 src/third_party/mozjs-38/extract/js/src/builtin/RegExp.cpp | grep endian.h

That's the first compile failure from your pastbin with '-M' substituted for the -o, which should let us see which file you're actually including as endian.h.

Troubleshooting, Errors when retrieving the public key; Errors when running sudo apt update; Errors Unable to install package due to dpkg-deb: error; mongod reports errors This error indicates that the /etc/apt/sources.list.d/mongodb-org-4.2.list may be​  [mongodb-user] building mongodb using visual studio 2010 [mongodb-user] building c++ driver: shared library and conveniently globbing/copying headers/examples, from v2.2.0 mongo source code [mongodb-user] Help with building of mongodb source code [mongodb-user] C++ 32-bit driver [mongodb-user] [beginner] "_filename.empty()" uncaught exception


Install MongoDB, Install MongoDB¶. On this page. MongoDB Community Edition Installation Tutorials; MongoDB Enterprise Edition Installation Tutorials; Upgrade Community​  The name MongoDB was derived from Hu mongo us DB. It is an open source NoSQL database. MongoDB is developed and commercially supported by the company 10gen. The focus of the MongoDB is on scalability and performance. MongoDB is a schema-free document-oriented database. This stores data as JSON objects.


[manjaro] compile MongoDB from source and install it manually , After installing it from the official repository, the mongo shell died with the following error: " Illegal instruction (core dumped)". Solution The  These errors indicate that the MongoDB Public GPG key was not added in step Import the public key used by the package management system of the Install MongoDB Community Edition procedure. Repeating the Import the public key used by the package management system step of the Install MongoDB Community Edition procedure typically resolves this issue. Ensure you are copying the command and key exactly as documented.


Compile and install MongoDB on Raspberry PI – Koen Aerts, 3) Download and unpack mongodb source code. scons: *** [build/opt/mongo/​scripting/mozjs/base.o] Error 1 scons: building terminated  Building the MongoDB PHP Driver from source For driver developers and people interested in the latest bugfixes, you can compile the driver from the latest source code on » Github . Run the following commands to clone and build the project: