mongo-cxx-driver installation error while running "make"

937 views
Skip to first unread message

Rodrigo Broggi

unread,
Oct 26, 2018, 8:22:13 PM10/26/18
to mongodb-user
Hi all,

I'm trying to build the cpp mongo db driver from source because I'm willing to contribute to the project :) . Unfortunately I'm running into some problems while following the installation procedure.

Context info: 
  1. I'm running OS X version 10.11. 
  2. I had no issues while installing the mongo-c-driver.
  3. clang version: 
$ clang++ --version
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0
Thread model: posix 
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

The error I'm facing is on  step 5 while running the "make" command and you can find in attachment the debug version while here below you can find the striped error:

In file included from /Users/rodrigobroggi/Documents/Workspace/cpp/mongo/mongo-cxx-driver/src/bsoncxx/array/element.cpp:15:
In file included from /Users/rodrigobroggi/Documents/Workspace/cpp/mongo/mongo-cxx-driver/src/bsoncxx/array/element.hpp:20:
In file included from /Users/rodrigobroggi/Documents/Workspace/cpp/mongo/mongo-cxx-driver/src/bsoncxx/document/element.hpp:20:
/Users/rodrigobroggi/Documents/Workspace/cpp/mongo/mongo-cxx-driver/src/bsoncxx/stdx/string_view.hpp:22:10: fatal error: 'core/string.hpp' file not found
#include <core/string.hpp>
         ^
1 error generated.
make[2]: *** [src/bsoncxx/CMakeFiles/bsoncxx.dir/array/element.cpp.o] Error 1
make[1]: *** [src/bsoncxx/CMakeFiles/bsoncxx.dir/all] Error 2
make: *** [all] Error 2

Than you in advance and have a great weekend,

Rodrigo Broggi 
 
make_debug.txt

Robert Cochran

unread,
Oct 27, 2018, 8:50:01 AM10/27/18
to mongodb-user
Hi!

I'm a Mac user myself (on High Sierra version 10.13.6 in my case.) I have not tried compiling this on my Mac, but 10.11 is a really old version, and so is your LLVM version. Mine is:

$ clang++ --version

Apple LLVM version 10.0.0 (clang-1000.11.45.2)

Target: x86_64-apple-darwin17.7.0



So I am wondering if the file not found error indicated by your output is because you are compiling with an outdated LLVM.

As an aside, recent versions of OS X have updates for a lot of security issues and I would suggest updating your OS X and XCode and the command line tools for XCode just to benefit from the improved security. 

I can't say that a general OS X and XCode upgrade will in fact resolve this error. I'm just suggesting that it might resolve it and additionally improve your system's security level. 

Thanks so much

Bob

Rodrigo Broggi

unread,
Oct 27, 2018, 3:54:49 PM10/27/18
to mongod...@googlegroups.com
Hi Robert,

Thank you for your suggestion. I tried to update my system but unfortunately this is the message of brew while trying to do so:

==> Upgrading 1 dependent:
mongodb 3.4.9 -> 4.0.3
mongodb: A full installation of Xcode.app 8.3.2 is required to compile this software.
Installing just the Command Line Tools is not sufficient.
Xcode 8.3.2 cannot be installed on macOS 10.11.
You must upgrade your version of macOS.
Error: mongodb: An unsatisfied requirement failed this build. 

The problem is that my hardware is not eligible for upgrading to newer versions of macOS.

Does anyone faced such issue before?

Thank you all in advance,
Best regards,

Rodrigo Broggi

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/79d7d4dc-0aae-44db-aa93-839ab0e76af3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rodrigo Broggi

unread,
Oct 27, 2018, 3:57:33 PM10/27/18
to mongod...@googlegroups.com
Maybe the best option in this case would be to use a docker container to compile the software... 
Anyone has other suggestions?

Best regards,

Rodrigo Broggi

Robert Cochran

unread,
Oct 27, 2018, 5:16:49 PM10/27/18
to mongodb-user
Does your hardware really support virtualization? It must be really old. The processor on your machine might not support virtualization extensions. 

In that case I think you may need to buy entirely new hardware that runs a modern operating system.

Thanks so much

Bob

Andrew Morrow

unread,
Oct 27, 2018, 6:10:44 PM10/27/18
to mongod...@googlegroups.com

Hi -

It looks like you are using the MNMLSTC polyfill. Did you run the following command from the instructions you linked to?

# Only for MNMLSTC polyfill
sudo make EP_mnmlstc_core

Also, it would be helpful if you showed the complete CMake and build invocations you have executed that led to that error. Another option would be to use the boost polyfill, since it looks like you are using homebrew it should be easy to install that. Then you wouldn't need the above step, though you may need to add directories to your compiler header and library search paths depending on where you have brew installed.

Thanks,
Andrew

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.

Rodrigo Broggi

unread,
Oct 27, 2018, 8:19:11 PM10/27/18
to mongod...@googlegroups.com
Hi all,

Thank you for your suggestions. I've tried to install over a docker container using the same install procedure but still no luck... This time I'm facing the following error (faced on mac too):

While running the cmake command:

root@a98ce7b12faa:/home/mongo-cxx-driver/build# cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..

The following error showed up:

CMake Error at src/bsoncxx/CMakeLists.txt:81 (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:

    libbson-1.0Config.cmake
    libbson-1.0-config.cmake

  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!

Any clue? I'm about to give up :( ...

Thank you for your hints so far...

Rodrigo Broggi

Robert Cochran

unread,
Oct 27, 2018, 8:40:00 PM10/27/18
to mongodb-user
Hi,

Andrew has a good point, I didn't think about a polyfill. Instead of installing a virtual machine (which can be big distraction in and of itself) have you tried his suggestion?

You may have to 'make clean' (or the make equivalent for that) and then start over again.

When I compiled the driver, I had to start over again a few times before I got it right. Sometimes the only magic needed is to try again, each mistake leads to careful review of the instructions (I reviewed the build instructions more than several times!) and then your understanding increases a bit and you try a new strategy.

I admit for my part that I have newer equipment and a newer operating system.

Try again...and again.

Also, please post the output that Andrew mentions.

Thanks so much

Bob

Andrew Morrow

unread,
Oct 28, 2018, 8:39:13 AM10/28/18
to mongod...@googlegroups.com

Don't give up! We will figure this out.

You said in your original post that you installed the MongoDB C driver. How did you do so? What does mdfind -name libbson-1.0-config.cmake say? Have you specified CMAKE_PREFIX_PATH to the installation root for the C driver as indicated in step 4 of the C++ driver build instructions?

Also, please note that you don't need to necessarily do your own build of the C driver to work on the C++ driver, you can just brew install mongo-c-driver and use that. In my setup, where I have the C driver installed to /usr/local via brew, the following works for me without modification to configure the C++ driver build: 

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..

And again, if you are using homebrew, I really might steer you towards the boost polyfills:

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBSONCXX_POLY_USE_BOOST=1 ..

You will need to brew install boost for that to work of course.

Thanks,
Andrew



Rodrigo Broggi

unread,
Oct 28, 2018, 6:42:12 PM10/28/18
to mongod...@googlegroups.com
Hi all,

I finally managed to compile it under my ubuntu image and I think I will make a Dockerfile and publish it to Docker hub to help other fellows facing similar issues (with the hope to save someone else some time :) ). Do you have any clue if there is a more suitable place to publish my experience (in the form of a Dockerfile)? 
The problem I was facing inside the container was due to the fact that I was installing mongo-c-driver using "apt-get" package manager while trying to install the mongo-cxx-driver using cmake (hoping to being able to compile and deploy/test some of my future contributions to the project :) ) - in this case, the "find_package" directive on the CMakeLists.txt doesn't work since "apt-get" does not care to put under "/usr/local/lib" the cmake configuration files (e.g.: /usr/local/lib/cmake/libmongoc-1.0/libmongoc-1.0-config.cmake). The result is that the compilation of the cxx plugin fails on the cmake directive. 
I will try, later on, to perform the installation also on my hardware even though the idea of containerizing the project is somewhat tempting, specially considering the number of versions of the project.

Special thanks to Bob and Andrew who assisted me with valuable hints ;) .

Hoping to soon being useful to the project :),

Best regards,

Rodrigo Broggi

Robert Cochran

unread,
Oct 28, 2018, 7:54:30 PM10/28/18
to mongodb-user
Hi!

I think you can upload your image to your own repository on the Docker website. I believe every Docker user can have their own Docker image repository. I myself am not experienced with Docker, but I do have the Docker engine running on my own system.

I understand your issue a little better now. It sounds like you were trying to get the mongo-c-driver from a Ubuntu package. I bet the package version on the Ubuntu repositories is really old. What I do on my system is to always compile from source code. I download the very latest announced source build and build it myself, following the instructions published by the driver team. I generally have to re-do the compiling/building process a couple times to "get the hang of it" and do it correctly.

Also, I compile and build to my own personal library, instead of to the system libraries. I keep everything in $HOME/local. For example compiling these 

drwxr-xr-x  8 vagrant vagrant    4096 Oct 15 18:40 mongo-c-driver-1.13.0
-rw-rw-r--  1 vagrant vagrant 6273122 Sep 17 15:12 mongo-c-driver-1.13.0.tar.gz
drwxrwxr
-x 12 vagrant vagrant    4096 Oct 15 18:55 mongo-cxx-driver



with a target of $HOME/local yields:

vagrant@entmdb4:~$ ls -al local/lib

total 3780

drwxrwxr-x 4 vagrant vagrant    4096 Oct 15 18:55 .

drwxrwxr-x 6 vagrant vagrant    4096 Oct 15 18:40 ..

drwxrwxr-x 8 vagrant vagrant    4096 Oct 15 18:55 cmake

lrwxrwxrwx 1 vagrant vagrant      16 Oct 15 18:40 libbson-1.0.so -> libbson-1.0.so.0

lrwxrwxrwx 1 vagrant vagrant      20 Oct 15 18:40 libbson-1.0.so.0 -> libbson-1.0.so.0.0.0

-rw-r--r-- 1 vagrant vagrant  254848 Oct 15 18:39 libbson-1.0.so.0.0.0

-rw-r--r-- 1 vagrant vagrant  405736 Oct 15 18:39 libbson-static-1.0.a

lrwxrwxrwx 1 vagrant vagrant      20 Oct 15 18:55 libbsoncxx.so -> libbsoncxx.so._noabi

-rw-r--r-- 1 vagrant vagrant  151352 Oct 15 18:47 libbsoncxx.so.3.4.0

lrwxrwxrwx 1 vagrant vagrant      19 Oct 15 18:55 libbsoncxx.so._noabi -> libbsoncxx.so.3.4.0

lrwxrwxrwx 1 vagrant vagrant      18 Oct 15 18:40 libmongoc-1.0.so -> libmongoc-1.0.so.0

lrwxrwxrwx 1 vagrant vagrant      22 Oct 15 18:40 libmongoc-1.0.so.0 -> libmongoc-1.0.so.0.0.0

-rw-r--r-- 1 vagrant vagrant  815168 Oct 15 18:39 libmongoc-1.0.so.0.0.0

-rw-r--r-- 1 vagrant vagrant 1459536 Oct 15 18:39 libmongoc-static-1.0.a

lrwxrwxrwx 1 vagrant vagrant      21 Oct 15 18:55 libmongocxx.so -> libmongocxx.so._noabi

-rw-r--r-- 1 vagrant vagrant  751456 Oct 15 18:49 libmongocxx.so.3.4.0

lrwxrwxrwx 1 vagrant vagrant      20 Oct 15 18:55 libmongocxx.so._noabi -> libmongocxx.so.3.4.0

drwxrwxr-x 2 vagrant vagrant    4096 Oct 15 18:55 pkgconfig



...and since my path will point to $HOME/local/lib, everything is happy:

vagrant@entmdb4:~/code/cxx$ export PKG_CONFIG_PATH="$HOME/local/lib/pkgconfig"

vagrant@entmdb4:~/code/cxx$ c++ --std=c++11 test.cpp -o test $(pkg-config --cflags --libs libmongocxx) -Wl,-rpath,/home/vagrant/local/lib

vagrant@entmdb4:~/code/cxx$ ls -al

total 64

drwxrwxr-x 2 vagrant vagrant  4096 Oct 28 19:45 .

drwxrwxr-x 3 vagrant vagrant  4096 Oct 15 19:00 ..

-rwxrwxr-x 1 vagrant vagrant 51584 Oct 28 19:45 test

-rw-rw-r-- 1 vagrant vagrant   598 Oct 28 19:40 test.cpp



and when I run it, I get this output:

vagrant@entmdb4:~/code/cxx$ ./test

{ "_id" : { "$oid" : "5bc51e5177350044294fef12" }, "hello" : "world" }

{ "_id" : { "$oid" : "5bd64b41773500079e14eae2" }, "hello" : "Bob" }




That isn't too bad...for a beginner like me... (smile.)

Thanks so much

Bob
Reply all
Reply to author
Forward
0 new messages