windows下安装mongodb驱动

2020-09-24  本文已影响0人  草丛里的黄盖

本文章仅作为个人笔记

解压下载的相关文件

msys2安装

    pacman --noconfirm -Syu
    pacman --noconfirm -S mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake
    pacman --noconfirm -S mingw-w64-x86_64-extra-cmake-modules make tar
    pacman --noconfirm -S mingw64/mingw-w64-x86_64-cyrus-sasl
    pacman --noconfirm -S git

libbson安装

    tar -zxvf libbson-1.9.5.tar.gz
    cd libbson-1.9.5
    mkdir cmake-build
    cd cmake-build
    CC=/mingw64/bin/gcc.exe /mingw64/bin/cmake -fPIC -G "MSYS Makefiles" -DCMAKE_INSTALL_PREFIX="/D/Develop/mongo/libbson" -DCMAKE_C_FLAGS="-D__USE_MINGW_ANSI_STDIO=1" ..
    make install

mongo-c-driver安装

    tar -zxvf mongo-c-driver-1.16.2.tar.gz
    cd mongo-c-driver-1.16.2
    mkdir cmake-build
    cd cmake-build
    CC=/mingw64/bin/gcc.exe /mingw64/bin/cmake -fPIC -G "MSYS Makefiles" -DCMAKE_INSTALL_PREFIX="/D/Develop/mongo/mongocdriver" -DCMAKE_PREFIX_PATH="/D/Develop/mongo/libbson" -DCMAKE_C_FLAGS="-D__USE_MINGW_ANSI_STDIO=1" ..
    make install

mongo-cxx-driver安装

    tar -zxvf r3.4.2.tar.gz
    cd mongo-cxx-driver-r3.4.2/build
    CC=/mingw64/bin/gcc.exe /mingw64/bin/cmake -fPIC -G "MSYS Makefiles" -DBUILD_SHARED_LIBS_WITH_STATIC_MONGOC=ON -DCMAKE_INSTALL_PREFIX="/D/Develop/mongo/mongocxxdriver" -DCMAKE_PREFIX_PATH="D:\Develop\mongo\mongocdriver" -DCMAKE_C_FLAGS="-D__USE_MINGW_ANSI_STDIO=1" ..
    make install

添加环境变量

    libbsoncxx_DIR
    D:\Develop\mongo\mongocxxdriver\lib\cmake\libbsoncxx-3.4.2
    libmongocxx_DIR
    D:\Develop\mongo\mongocxxdriver\lib\cmake\libmongocxx-3.4.2
    LIBBSONCXX_LIBRARIES
    D:\Develop\mongo\mongocxxdriver\lib
    LIBBSONCXX_LIBRARIES
    D:\Develop\mongo\mongocxxdriver\lib
上一篇下一篇

猜你喜欢

热点阅读