[CXX-1705] mongodb c++ driver on ubuntu Created: 20/Dec/18  Updated: 27/Oct/23  Resolved: 01/Jan/19

Status: Closed
Project: C++ Driver
Component/s: Testing
Affects Version/s: 3.4.0
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: NGUYEN KHAC Tho Assignee: Unassigned
Resolution: Works as Designed Votes: 0
Labels: driver
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

ubuntu 16.04


Issue Links:
Duplicate

 Description   

Hello,

I am trying to test mongodb c++ driver on ubuntu 16.04.

 

The driver is installed in ${Devfolder}/sdk/mongodb/ and the test is in ${Devfolder}/testMongoDb/.

The code was compliled and tested using:
 
{{export PKG_CONFIG_PATH=${Devfolder}/sdk/mongodb/lib/pkgconfigexport LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${Devfolder}/sdk/mongodb/lib
c++ --std=c++11 test.cpp -o test $(pkg-config --cflags --libs libmongocxx)}}

Then I want to use mongodb driver in my CMake project.
 
 
{{ugitho@ugitho:build$ cmake ..CMake Error at CMakeLists.txt:6 (find_package):By not providing "Findlibbsoncxx.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by "libbsoncxx", but CMake did not find one.Could not find a package configuration file provided by "libbsoncxx" with
any of the following names: libbsoncxxConfig.cmake
libbsoncxx-config.cmake Add the installation prefix of "libbsoncxx" to CMAKE_PREFIX_PATH or set"libbsoncxx_DIR" to a directory containing one of the above files. If"libbsoncxx" provides a separate development package or SDK, be sure it has
been installed.-- Configuring incomplete, errors occurred!See also "/home/ugitho/NGUYENKHAC/projects/testMongo/build/CMakeFiles/CMakeOutput.log".}}

Here are CMakeLists.txt and test.cpp.

CMakeLists.txt:
 
cmake_minimum_required(VERSION 3.10)project(cmongodb)set(CMAKE_CXX_STANDARD 14)find_package(libbsoncxx REQUIRED)find_package(libmongocxx REQUIRED)include_directories(${LIBMONGOCXX_INCLUDE_DIRS} ${LIBBSONCXX_INCLUDE_DIRS})link_directories(${LIBMONGOCXX_LIBRARY_DIRS} ${LIBBSONCXX_LIBRARY_DIRS})add_executable(cmongodb test.cpp)target_link_libraries(cmongodb ${LIBMONGOCXX_STATIC_LIBRARIES} ${LIBBSONCXX_STATIC_LIBRARIES})

test.cpp:
 
#include <iostream>#include <bsoncxx/builder/stream/document.hpp>#include <bsoncxx/json.hpp>#include <mongocxx/client.hpp>#include <mongocxx/instance.hpp>int main(int, char **) { std::cout << "1" << std::endl; mongocxx::instance inst{}; mongocxx::client conn{mongocxx::uri{; bsoncxx::builder::stream::document document{};auto collection = conn["testdb"]["testcollection"]; document << "hello"<< "world"; collection.insert_one(document.view());auto cursor = collection.find({});for (auto &&doc : cursor)

{ std::cout << bsoncxx::to_json(doc) << std::endl;}

return 0;}}}

Do you have any idea about what I missed here?

 

https://stackoverflow.com/questions/53857863/mongodb-c-driver-on-ubuntu

 



 Comments   
Comment by NGUYEN KHAC Tho [ 02/Jan/19 ]

Hi Kevin,

Thanks for the answer.
I managed to add the path into my CMakeLists.

Kind regards,

Tho NGUYEN KHAC
Software Engineer
1 Parvis de la Bièvre
92160 ANTONY
Tél: 00 33 6 51 53 71 02

On Tue, 1 Jan 2019 at 18:30, Kevin Albertson (Jira) <jira@mongodb.org>

Comment by Kevin Albertson [ 01/Jan/19 ]

Hi Nguyen,

I commented on your stack overflow question with some more information. Since this is not a C++ driver bug or feature request, we can provide further assistance in the stack overflow question. But it seems like your issue was solved anyway.

Best,
Kevin

Comment by NGUYEN KHAC Tho [ 26/Dec/18 ]

Hi guys,

 

Do you have any ideas ?

I am really stuck on this issue.

Generated at Wed Feb 07 22:03:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.