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

安装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
相关推荐
A懿轩A1 小时前
C/C++ 数据结构与算法【数组】 数组详细解析【日常学习,考研必备】带图+详细代码
c语言·数据结构·c++·学习·考研·算法·数组
机器视觉知识推荐、就业指导1 小时前
C++设计模式:享元模式 (附文字处理系统中的字符对象案例)
c++
半盏茶香1 小时前
在21世纪的我用C语言探寻世界本质 ——编译和链接(编译环境和运行环境)
c语言·开发语言·c++·算法
Ronin3052 小时前
11.vector的介绍及模拟实现
开发语言·c++
✿ ༺ ོIT技术༻2 小时前
C++11:新特性&右值引用&移动语义
linux·数据结构·c++
字节高级特工2 小时前
【C++】深入剖析默认成员函数3:拷贝构造函数
c语言·c++
计算机学长大白3 小时前
C中设计不允许继承的类的实现方法是什么?
c语言·开发语言
远游客07138 小时前
centos stream 8下载安装遇到的坑
linux·服务器·centos
jingyu飞鸟8 小时前
centos-stream9系统安装docker
linux·docker·centos
唐诺8 小时前
几种广泛使用的 C++ 编译器
c++·编译器