C++ Driver libbson-1.0 build error on CentOS 8

I am going through the installation steps exactly as they on the website so the commands I’m using are the same. When I am trying to configure the driver in step 4 using cmake, I am getting this error.

bsoncxx version: 3.6.2

CMake Error at src/bsoncxx/CMakeLists.txt:98 (find_package):
  By not providing "Findlibbson-1.0.cmake" in CMAKE_MODULE_PATH this project 
  has asked CMake to find a package configuration file provided by 
  "libbson-1.0", but CMake did not find one.

 Could not find a package configuration file provided by "libbson-1.0"
  (requested version 1.13.0) with any of the following names:


  Add the installation prefix of "libbson-1.0" to CMAKE_PREFIX_PATH or set
  "libbson-1.0_DIR" to a directory containing one of the above files.  If
  "libbson-1.0" provides a separate development package or SDK, be sure it
  has been installed.

-- Configuring incomplete, errors occurred!
See also "/root/mongo-cxx-driver-r3.6.2/build/CMakeFiles/CMakeOutput.log".

I have tried reinstalling just about everything but I haven’t gotten anywhere. I’m new to linux too so any gerneral guidance is appreciated!!

@Luke_Colias can you please provide the sequence of commands you used to configure, build, and install the C driver, along with the full output of each. Also, please provide the complete CMake command and output for the attempted C++ driver build.

1 Like

Hi @Luke_Colias,

I’ve successfully built the C/CXX drivers under Ubuntu 18.04 using the following:

export WORKDIR=/home/alex/Temp
export CDRIVER_VERSION=1.15.1
export LD_LIBRARY_PATH=/usr/local/lib
sudo apt-get update && sudo apt-get install -y build-essential wget cmake git pkg-config libssl-dev libsasl2-dev 
wget https://github.com/mongodb/mongo-c-driver/releases/download/${CDRIVER_VERSION}/mongo-c-driver-${CDRIVER_VERSION}.tar.gz && \
  tar xzf mongo-c-driver-${CDRIVER_VERSION}.tar.gz
cd ${WORKDIR}/mongo-c-driver-${CDRIVER_VERSION} && \
  mkdir cmake-build && \
  cd cmake-build && \
  make && sudo make install
wget https://github.com/mongodb/mongo-cxx-driver/archive/r${CPPDRIVER_VERSION}.tar.gz && \
  tar -xzf r${CPPDRIVER_VERSION}.tar.gz
cd ${WORKDIR}/mongo-cxx-driver-r${CPPDRIVER_VERSION}/build && \
  cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_PREFIX_PATH=/usr/local .. && \
  make EP_mnmlstc_core && \
  sudo make && sudo make install

As @Roberto_Sanchez pointed out, to troubleshoot we’d need the full set of steps you followed to build both drivers.

1 Like

I’m running these commands on centOS 8. Also I’m building these under the root directory, I know that’s probably not how I’m supposed to do it, but my advisor told me it would make things easier.
These are the commands I run for the c driver.

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
yum install mongo-c-driver
yum install libbson

sudo yum install cmake openssl-devel cyrus-sasl-devel

wget https://github.com/mongodb/mongo-c-driver/releases/download/1.17.3/mongo-c-driver-1.17.3.tar.gz
tar xzf mongo-c-driver-1.17.3.tar.gz
cd mongo-c-driver-1.17.3
mkdir cmake-build
cd cmake-build

cmake --build .

Now for the C++ driver I used:

curl -OL https://github.com/mongodb/mongo-cxx-driver/releases/download/r3.6.2/mongo-cxx-driver-r3.6.2.tar.gz
tar -xzf mongo-cxx-driver-r3.6.2.tar.gz
cd mongo-cxx-driver-r3.6.2/build

cmake ..                                \
    -DCMAKE_BUILD_TYPE=Release          \

At this last cmake command is where I’m getting the error from above. I understand that I’m getting the error because something isn’t installed in the right location I just don’t know where I went wrong because I’m still relatively new Linux in general.

1 Like

Thank you for your help, I’ll try to match these to the centOS commands and work at it from there. I added the commands I was using in my last reply.

1 Like

@Luke_Colias it does not make sense that you install the mongo-c-driver and libbson packages via yum and then try to build from source as well. If the packages available via yum are of a sufficiently recent version for you, then simply install the -devel packages of each and be done with it. If you need to build from source, then it is best to not also have the packages installed via yum at the same time. Apart from that, the commands you executed are helpful, but if you note my previous comment we need the full output to be able to effectively diagnose the issue. That said, based on the command sequence for the C driver, it looks like you built it but did not actually install it. You might need something like cmake --build . --target install (possibly with sudo if your installation prefix is in a system directory).


Okay I Think I understand more now, how would I install the -devel packages of the c driver and libbson? I get now that I installed them via yum so but I dont fully get the distinction between that and what the -devel package is.

@Luke_Colias you should be able to install them with yum install mongo-c-driver-devel libbson-devel.

1 Like

Awesome that worked, so now I should just have to follow the instructions for installing the c++ driver right?

That’s right. Just make sure that you select a C++ driver version that supports the C driver version you installed. (I don’t recall what version is available by default from CentOS 8).

1 Like

Okay It says the package that was installed is “(4/5): mongo-c-driver-devel-1.17.2-1.el8.x86_64” so I assume that means i can use the latest version of the c++ driver.

That sounds correct to me. The latest C++ driver requires C driver 1.17.0 or later.

Okay sweet, I ran the basic Cmake command:

cmake ..                                \
    -DCMAKE_BUILD_TYPE=Release          \

And everything looks good becasue its giving me this message at the end

 Build files have been written to: /root/mongo-cxx-driver-r3.6.2/build

Now when I run the build command do I have to add the mnmlstc core flagg becasue im really not sure about what that is.

(P.S. Also I appreciate all of this so much I was stuck on this forever and you just knocked out like 10 hours of frustration in like 20 min, thank you!)

1 Like

Correct. It is the same as I explained in the other thread. You are quite welcome.

Also I’m not really sure what the poly fill is. I know in the other post you said I have two option and those would be to use the compiler that C++17 support for my polyfill(which seems easiert). And the other option would be to download MNMLSTC code from guithub which sounds like more effort and i dont know if i even need it. I was thinking I could just run the command:

cmake --build .
sudo cmake --build . --target install

And this would be sufficent for me to start creating a project.

If you don’t want to use the MNMLSTC that the build tries to download and build for you, you will need to specify the option that you prefer. Have a look at Step 2 in the installation guide.

Okay from how I understand it, the MNMLSTC core is installed automatically and is the default for non-windows systems.
if I run

sudo cmake --build . --target EP_mnmlstc_core

It will install this for me?

The build defaults to downloading MNMLSTC_core from GitHub and using that for the polyfill. However, you do not install it as a specific target. That is handled by the normal building and installation of the overall driver.

1 Like

Okay I accidentially ran that command and it Said that it downloaded it.

[root@instance-1 build]#  sudo cmake --build . --target EP_mnmlstc_core
Scanning dependencies of target EP_mnmlstc_core
[  0%] Creating directories for 'EP_mnmlstc_core'
[  0%] Performing download step (git clone) for 'EP_mnmlstc_core'
-- EP_mnmlstc_core download command succeeded.  See also /root/mongo-cxx-driver-                                                                                                                                                                                               r3.6.2/build/src/bsoncxx/third_party/EP_mnmlstc_core-prefix/src/EP_mnmlstc_core-                                                                                                                                                                                               stamp/EP_mnmlstc_core-download-*.log
[  0%] No patch step for 'EP_mnmlstc_core'
[ 50%] No update step for 'EP_mnmlstc_core'
[ 50%] Performing configure step for 'EP_mnmlstc_core'
-- EP_mnmlstc_core configure command succeeded.  See also /root/mongo-cxx-driver                                                                                                                                                                                               -r3.6.2/build/src/bsoncxx/third_party/EP_mnmlstc_core-prefix/src/EP_mnmlstc_core                                                                                                                                                                                               -stamp/EP_mnmlstc_core-configure-*.log
[ 50%] Performing build step for 'EP_mnmlstc_core'
-- EP_mnmlstc_core build command succeeded.  See also /root/mongo-cxx-driver-r3.                                                                                                                                                                                               6.2/build/src/bsoncxx/third_party/EP_mnmlstc_core-prefix/src/EP_mnmlstc_core-sta                                                                                                                                                                                               mp/EP_mnmlstc_core-build-*.log
[ 50%] Performing install step for 'EP_mnmlstc_core'
-- EP_mnmlstc_core install command succeeded.  See also /root/mongo-cxx-driver-r                                                                                                                                                                                               3.6.2/build/src/bsoncxx/third_party/EP_mnmlstc_core-prefix/src/EP_mnmlstc_core-s                                                                                                                                                                                               tamp/EP_mnmlstc_core-install-*.log
[100%] Performing fix-includes step for 'EP_mnmlstc_core'
[100%] Completed 'EP_mnmlstc_core'
[100%] Built target EP_mnmlstc_core
[root@instance-1 build]# cmake --build .
[  2%] Built target EP_mnmlstc_core
Scanning dependencies of target bsoncxx_testing

I think that means im okay to build and install right.

Yes, you should be able to continue as normal. The build instructions do not say to run the EP_mnmlstc_core target because not every build will have it. The build figures out if that target is needed based on the CMake options provided and then handles any build and install steps required for that.