Building C MongoDB Driver - linux-on-ibm-z/docs GitHub Wiki

Building MongoDB C Driver

Below versions of MongoDB C Driver are available in respective distributions at the time creation of these build instructions:

  • RHEL (8.10, 9.6, 9.8) have 1.30.13
  • RHEL (10.0, 10.2) have 2.5.6
  • Ubuntu 22.04 has 1.21.0
  • Ubuntu 24.04 has 1.26.0

Note: The instructions provided below specify the steps to build MongoDB C Driver version 2.5.8 on Linux on IBM Z for following distributions:

  • Ubuntu (22.04, 24.04)
  • RHEL (8.10, 9.6, 9.8, 10.0, 10.2)

General Notes:

  • When following the steps below please use a standard permission user unless otherwise specified.
  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it. MongoDB C Driver can be installed with Package Manager as mentioned here

1. Install MongoDB C Driver

1.1. Install dependencies

export SOURCE_ROOT=/<source_root>/
  • Ubuntu (22.04, 24.04)

    sudo apt-get update
    sudo apt-get install -y cmake gcc libsasl2-dev libssl-dev make pkg-config tar wget curl
    
  • RHEL (8.10, 9.6, 9.8, 10.0, 10.2)

    sudo yum install -y cmake gcc openssl-devel cyrus-sasl-devel make pkg-config tar wget curl diffutils
    

1.2. Configure, build and install the MongoDB C Driver

cd $SOURCE_ROOT
wget https://github.com/mongodb/mongo-c-driver/archive/refs/tags/2.5.8.tar.gz
tar -xzf 2.5.8.tar.gz
cd mongo-c-driver-2.5.8
mkdir cmake-build
cd cmake-build
cmake -D BUILD_VERSION="2.5.8" ..
make
sudo make install
sudo ldconfig
#Required before compiling and running sample application
export LD_LIBRARY_PATH=/usr/local/lib64                   # For RHEL
export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig         # For RHEL

2. Verification (Optional)

Refer to the official MongoDB C Driver Getting Started guide here

References: