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
相关推荐
博客18002 天前
酷宝的使用方法,超好用的免费界面库,C++、MFC可用
c++·mfc·界面库·库来帮·酷宝
郝学胜_神的一滴2 天前
CMake 026:属性体系精讲、四大作用域全解 & 实战代码落地
c++·cmake
众少成多积小致巨2 天前
JNI (Java Native Interface) 技术手册中文参考指南
android·java·c++
clint4567 天前
C++进阶(1)——前景提要
c++
夜悊7 天前
C++代码示例:进制数简单生成工具
c++
郝学胜_神的一滴7 天前
CMake 021: IF 条件判据详诠
c++·cmake
_wyt0017 天前
洛谷 B3930 [GESP202312 五级] 烹饪问题 题解
c++·gesp
LDR0067 天前
Type-C 快充全面升级!LDR6601 赋能个人护理便携电机,重塑剃须刀 / 理发器新体验
c语言·开发语言
Luminous.7 天前
C语言--day30
c语言·开发语言
玖玥拾8 天前
C/C++ 数据结构(七)栈、容器适配器
c语言·数据结构·c++··容器适配器