Add MongoDB 4.2 ARM64 builds for Raspberry Pi OS 64 bit (Debian Buster)

@Kristof_Moors (and CC @Joshua_Maserow) -

Here are instructions for doing a Debian 10 ARM build of MongoDB Community v4.2.8 for RPi4 from a Debian 10 x86-64 machine. Note that since this is built from the community sources, no enterprise features will be available:

$ sudo apt-get install gcc-8-aarch64-linux-gnu g++-8-aarch64-linux-gnu
$ sudo dpkg --add-architecture arm64
$ sudo apt-get update
$ sudo apt-get install libssl-dev:arm64 libcurl4-openssl-dev:arm64

$ git clone -b r4.2.8 https://github.com/mongodb/mongo.git
$ cd mongo

# Consider using a virtualenv for this
$ python3 -m pip install --user -r etc/pip/compile-requirements.txt

$ python3 buildscripts/scons.py --ssl CC=/usr/bin/aarch64-linux-gnu-gcc-8 CXX=/usr/bin/aarch64-linux-gnu-g++-8 CCFLAGS="-march=armv8-a+crc -mtune=cortex-a72" ./mongo{,s,d}

The above build took about 25 minutes for me on a 16 vCPU Debian 10 x86_64 machine, so be prepared to wait a little while. By default it will use all cores to build, so if you want to not saturate your machine, you can add an explicit -j N argument to limit to N cores.

If the build completes OK, you will find mongo, mongod, and mongos binaries in the root of the tree. The binaries will be very large because they are unstripped, but you can strip them if you want. You can then transfer what you need to the RPi4. I don’t have one to test on, so I can’t promise the binaries work: please try them out and let us know.

If you want to try building on the RPi4 itself as a native build, you can simplify the above instructions to something like the following, which is untested:

$ sudo apt-get install gcc-8 g++-8
$ sudo apt-get install libssl-dev libcurl4-openssl-dev

$ git clone -b r4.2.8 https://github.com/mongodb/mongo.git
$ cd mongo

# Consider using a virtualenv for this
$ python3 -m pip install --user -r etc/pip/compile-requirements.txt

$ python3 buildscripts/scons.py --ssl CC=gcc-8 CXX=g++-8 CCFLAGS="-march=armv8-a+crc -mtune=cortex-a72" ./mongo{,s,d}

But I have no idea how long that will take to build, and I don’t have an RPi4 on which to try it out.

Hope this helps,
Andrew

PS Any reason you want v4.2 not the newly released v4.4? The v4.4 release has some build improvements that can make the process a little simpler. Please let me know if you want v4.4 specific instructions.

2 Likes