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
相关推荐
敲上瘾4 分钟前
操作系统的理解
linux·运维·服务器·c++·大模型·操作系统·aigc
不会写代码的ys10 分钟前
【类与对象】--对象之舞,类之华章,共绘C++之美
c++
兵哥工控12 分钟前
MFC工控项目实例三十二模拟量校正值添加修改删除
c++·mfc
长弓聊编程22 分钟前
Linux系统使用valgrind分析C++程序内存资源使用情况
linux·c++
陌小呆^O^26 分钟前
Cmakelist.txt之win-c-udp-client
c语言·开发语言·udp
cherub.29 分钟前
深入解析信号量:定义与环形队列生产消费模型剖析
linux·c++
暮色_年华44 分钟前
Modern Effective C++item 9:优先考虑别名声明而非typedef
c++
重生之我是数学王子1 小时前
QT基础 编码问题 定时器 事件 绘图事件 keyPressEvent QT5.12.3环境 C++实现
开发语言·c++·qt
传而习乎1 小时前
Linux:CentOS 7 解压 7zip 压缩的文件
linux·运维·centos
我们的五年1 小时前
【Linux课程学习】:进程程序替换,execl,execv,execlp,execvp,execve,execle,execvpe函数
linux·c++·学习