Mongodb C++ driver - test code doesnt work

1,253 views
Skip to first unread message

svaidya

unread,
Jul 5, 2016, 8:53:24 AM7/5/16
to mongodb-user
Hi,


I get an error while building the mongo-cxx-driver:

[PKG_CONFIG_PATH=CDRIVER_INSTALL_PATH/lib/pkgconfig] cmake -DCMAKE_BUILD_TYPE=Release [-DCMAKE_INSTALL_PREFIX=/usr/local] ..

-bash: [PKG_CONFIG_PATH=CDRIVER_INSTALL_PATH/lib/pkgconfig]: No such file or directory


So instead I used


-bash: [PKG_CONFIG_PATH=/usr/local/lib/pkgconfig]: No such file or directory

Smritis-MacBook-Pro:build smritivaidya$ cmake -DCMAKE_BUILD_TYPE=Release [-DCMAKE_INSTALL_PREFIX=/usr/local] ..

-- The CXX compiler identification is AppleClang 7.3.0.7030031

-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++

-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works

-- Detecting CXX compiler ABI info

-- Detecting CXX compiler ABI info - done

-- Detecting CXX compile features

-- Detecting CXX compile features - done

-- The C compiler identification is AppleClang 7.3.0.7030031

-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc

-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works

-- Detecting C compiler ABI info

-- Detecting C compiler ABI info - done

-- Detecting C compile features

-- Detecting C compile features - done

-- Checking for module 'libbson-1.0>=1.3.1'

--   Found libbson-1.0, version 1.3.5

-- Found LIBBSON: TRUE  

-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY

-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success

-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY

-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success

-- Performing Test COMPILER_HAS_DEPRECATED_ATTR

-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success

-- Checking for module 'libmongoc-1.0>=1.3.1'

--   Found libmongoc-1.0, version 1.3.5

-- Found LIBMONGOC: TRUE  

-- Configuring done

-- Generating done

-- Build files have been written to: /Users/smritivaidya/Desktop/KhanAcademy/mongo-cxx-driver/build

Smritis-MacBook-Pro:build smritivaidya$ ls

CMakeCache.txt CTestTestfile.cmake cmake_install.cmake examples


But when I try to run the test code given in the Quick Starter guide I get the error:


g++ -c --std=c++11 -Wall -I/usr/local/include/mongocxx/v0.3 -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/bsoncxx/v0.3 -I/usr/local/include/libbson-1.0 -c hellomongo.cpp

hellomongo.cpp:3:10: fatal error: 'bsoncxx/builder/stream/document.hpp' file not found

#include <bsoncxx/builder/stream/document.hpp>

         ^

1 error generated.

make: *** [hellomongo.o] Error 1 



David Golden

unread,
Jul 5, 2016, 5:41:32 PM7/5/16
to mongodb-user
The parts in brackets like [PKG_CONFIG_PATH=/usr/local/lib/pkgconfig] aren't meant to be typed literally.  They are meant to be included only if you need them (i.e. if you installed libmongoc in a non-standard location).  The same with [-DCMAKE_INSTALL_PREFIX=/usr/local].

More specifically, though, I don't see that you ran make && sudo make install before compiling the test program.

Let me know if that fixes the problem.

Regards,
David

Mohammad Ahmadian

unread,
Jul 26, 2016, 6:14:08 PM7/26/16
to mongodb-user
Hi Mr. Golden

I am trying to build and install mongodb c++ driver on my machine (Ubuntu 16.04)  according to the manual at https://github.com/mongodb/mongo-cxx-driver/wiki/Quickstart-Guide-(New-Driver)

This is all instructions that I issued:

2- cd mongo-cxx-driver/build
3- export PKG_CONFIG_PATH=/usr/local/pkgconfig
4- cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..
5- make && sudo make install
[  0%] Performing install step for 'EP_mnmlstc_core'
CMake Error at /home/m/Downloads/mongo-cxx-driver/build/src/bsoncxx/third_party/EP_mnmlstc_core-prefix/src/EP_mnmlstc_core-stamp/EP_mnmlstc_core-install-Release.cmake:16 (message):
  Command failed: 2

   'make' 'install'

  See also

    /home/m/Downloads/mongo-cxx-driver/build/src/bsoncxx/third_party/EP_mnmlstc_core-prefix/src/EP_mnmlstc_core-stamp/EP_mnmlstc_core-install-*.log


src/bsoncxx/third_party/CMakeFiles/EP_mnmlstc_core.dir/build.make:74: recipe for target 'src/bsoncxx/third_party/EP_mnmlstc_core-prefix/src/EP_mnmlstc_core-stamp/EP_mnmlstc_core-install' failed
make[2]: *** [src/bsoncxx/third_party/EP_mnmlstc_core-prefix/src/EP_mnmlstc_core-stamp/EP_mnmlstc_core-install] Error 1
CMakeFiles/Makefile2:304: recipe for target 'src/bsoncxx/third_party/CMakeFiles/EP_mnmlstc_core.dir/all' failed
make[1]: *** [src/bsoncxx/third_party/CMakeFiles/EP_mnmlstc_core.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2

Please help me to resolve this problem. I appreciate your help and your time. 

Best,
Mohammad Ahmadian

Andrew Morrow

unread,
Aug 5, 2016, 8:50:08 AM8/5/16
to mongod...@googlegroups.com

Hi -

What is strange about your problem is that it looks as if the build isn't trying to clone the MNMLSTC repo from github at all. We have many continuous integration systems running these commands, and they work reliably. It looks like your build hasn't event attempted to download the MNMLSTC headers, and is trying to immediately build it, which isn't going to work.

Did you take CMake's suggestion to look at the log files? Is there anything interesting in them? I'm referring to the following files:

/home/m/Downloads/mongo-cxx-driver/build/src/bsoncxx/third_party/EP_mnmlstc_core-prefix/src/EP_mnmlstc_core-stamp/EP_mnmlstc_core-install-*.log

If, for some reason, you really can't get the MNMLSTC build to work, you could also select a different source for the bsoncxx::stdx polyfills. If you have boost, for instance, you can use that.


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+unsubscribe@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/bd6484b1-861d-4274-97c1-85aaa6f50e58%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Kartik Desai

unread,
Feb 22, 2017, 12:34:11 AM2/22/17
to mongodb-user
Hey david I was also facing the same problem and   I don't see that you ran make && sudo make install before compiling the test program. this solution worked for me and I am able to compile the program. executable is generated but get this error now :  

/test: error while loading shared libraries: libmongocxx.so._noabi: cannot open shared object file: No such file or directory

David Golden

unread,
Feb 22, 2017, 4:22:00 PM2/22/17
to mongodb-user
Hi, Kartik.

What operating system are you using?  Could you please post the exact commands you ran and the corresponding output?

Thanks,
David

Gerard Suades

unread,
Aug 8, 2017, 9:53:32 AM8/8/17
to mongodb-user
I have the same error as Kartik Desai.

I amb using Ubuntu 16.04, mongo-c-driver-1.6.3.tar.gz and mongo-cxx-driver r3.1.2.tar.gz

I compiled C driver and C++ as described in https://mongodb.github.io/mongo-cxx-driver/mongocxx-v3/installation/ defining /usr/local as a prefix path

Test defined in Step 6 doesn't work for me. I compiled it with:
c++ --std=c++11 test.cpp -o test $(pkg-config --cflags --libs libmongocxx)

I also definied export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig"

It compiles without errors but when I try to execute with ./test it raises the following error:
./test: error while loading shared libraries: libmongocxx.so._noabi: cannot open shared object file: No such file or directory

libmongocxx.so._noabi is localted /usr/local/lib with a link to libmongocxx.so.3.1.2 => libmongocxx.so._noabi -> libmongocxx.so.3.1.2

Do you know what can be wrong or what can I look for to be able to run the test without errors?

Thanks,


El dimecres, 22 febrer de 2017 22:22:00 UTC+1, David Golden va escriure:

Gerard Suades

unread,
Aug 8, 2017, 9:54:19 AM8/8/17
to mongodb-user
Hi,

I had the same problema and finally solved the issue as Claudio Palumbo said in this other thread => https://groups.google.com/forum/#!topic/mongodb-user/t9I2QPAkTSg

Performing an apt-get update & apt-get upgrade to Ubuntu 16.04

Seems that some compiler + libraries needs to be updated. After that the same compiled test runs just fine.

Hope this could help :D

El dimecres, 22 febrer de 2017 22:22:00 UTC+1, David Golden va escriure:
Hi, Kartik.
Reply all
Reply to author
Forward
0 new messages