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
相关推荐
lb36363636363 小时前
介绍一下数组(c基础)(详细版)
c语言
李元豪3 小时前
【智鹿空间】c++实现了一个简单的链表数据结构 MyList,其中包含基本的 Get 和 Modify 操作,
数据结构·c++·链表
UestcXiye3 小时前
《TCP/IP网络编程》学习笔记 | Chapter 9:套接字的多种可选项
c++·计算机网络·ip·tcp
一丝晨光4 小时前
编译器、IDE对C/C++新标准的支持
c语言·开发语言·c++·ide·msvc·visual studio·gcc
丶Darling.5 小时前
Day40 | 动态规划 :完全背包应用 组合总和IV(类比爬楼梯)
c++·算法·动态规划·记忆化搜索·回溯
奶味少女酱~5 小时前
常用的c++特性-->day02
开发语言·c++·算法
我是哈哈hh6 小时前
专题十八_动态规划_斐波那契数列模型_路径问题_算法专题详细总结
c++·算法·动态规划
ac.char6 小时前
在CentOS下安装RabbitMQ
linux·centos·rabbitmq
执笔者5486 小时前
C语言:函数栈帧的创建与销毁
c语言
_小柏_7 小时前
C/C++基础知识复习(15)
c语言·c++