Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-1705

mongodb c++ driver on ubuntu

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • 3.4.0
    • Testing
    • ubuntu 16.04

    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

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            ugitho NGUYEN KHAC Tho
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: