centos下安装mongo C & C++ 驱动

发布时间:2024年01月24日

安装mongo-cxx-driver-r3.4.0?cmake的时候报错:??

报错:

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

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

    libmongoc-1.0Config.cmake
    libmongoc-1.0-config.cmake

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

原因:? mondo-c-drive没有安装或者没有正确安装?

报错:

CMake Error at src/libmongoc/cmake_install.cmake:155 (file):
  file cannot create directory: /usr/local/include/libmongoc-1.0/mongoc.
  Maybe need administrative privileges.
Call Stack (most recent call first):
  cmake_install.cmake:43 (include)

因为之前安装过 所有/usr/local/include/libmongoc-1.0 这个库存在? 备份或者删除 重新安装

cd /usr/local/include/libbson-1.0/ 

mv libmongoc-1.0 libmongoc-1.0.bak



 libmongoc 清除之后重新安装 
 

cd cmake-build 
 
make clean 

make 
make install 

安装libbson 1.0.0版本

找到需要的版本

wget https://github.com/mongodb/libbson/releases/download/1.0.0/libbson-1.0.0.tar.gz


tar -zxvf libbson-1.0.0.tar.gz

cd libbson-1.0.0

./autogen.sh 

make 

make install 

?

安装libmongo C 驱动

wget https://github.com/mongodb/mongo-c-driver/releases/download/1.13.1/mongo-c-driver-1.13.1.tar.gz

tar -zxvf 1.13.1.tar.gz 

cd mongo-c-driver-1.13.1

#新建编译路径
mkdir cmake-build

cd cmake-build

#执行编译   后面两个点 上级路径

cmake -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF .. 


make

make install  

安装libmong CXX版本

wget https://github.com/mongodb/mongo-cxx-driver/archive/refs/tags/r3.4.0.tar.gz

tar -zxvf r3.4.0.tar.gz

cd mongo-cxx-driver-r3.4.0/build



#编译   注意空格 
cmake .. -DCMAKE_BUILD_TYPE=Release  
-DBUILD_SHARED_LIBS_WITH_STATIC_MONGOC=ON 
-DBSONCXX_POLY_USE_SYSTEM_MNMLSTC=0 
-DCMAKE_PREFIX_PATH=/usr/local/lib/ 
-DCMAKE_INSTALL_PREFIX=/usr/local

文章来源:https://blog.csdn.net/dwl764457208/article/details/135830359
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。