1.windows 10下安装 git
git clone https://github.com/mongodb/mongo-c-driver.git
拖到本地,然后mkdir cmake_build ; cd cmake_build 新建一个目录用于build,然后进入该目录;
运行命令;安装 vs2019后,有一个命令提示符工具:Developer Command Prompt for VS 2019 ,用这个命令提示符运行下面的命令;不知道自己的build_version 可以运行cmake --version 会提示3.17....之类的;
cmake -DBUILD_VERSION="3.17.20032601-MSVC_2" -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF ..
以下为输出:
C:\Git\mongo-c-driver\cmake-build>cmake -DBUILD_VERSION="3.17.20032601-MSVC_2" -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF ..
-- No CMAKE_BUILD_TYPE selected, defaulting to RelWithDebInfo
storing BUILD_VERSION 3.17.20032601-MSVC_2 in file VERSION_CURRENT for later use
-- Build and install static libraries
-- Using bundled libbson
libbson version (from VERSION_CURRENT file): 3.17.20032601-pre
-- Check if the system is big endian
-- Searching 16 bit integer
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Searching 16 bit integer - Using unsigned short
-- Check if the system is big endian - little endian
-- Looking for snprintf
-- Looking for snprintf - found
-- Looking for reallocf
-- Looking for reallocf - not found
-- Performing Test BSON_HAVE_TIMESPEC
-- Performing Test BSON_HAVE_TIMESPEC - Success
-- struct timespec found
-- Looking for gmtime_r
-- Looking for gmtime_r - not found
-- Looking for rand_r
-- Looking for rand_r - not found
-- Looking for strings.h
-- Looking for strings.h - not found
-- Looking for strlcpy
-- Looking for strlcpy - not found
-- Performing Test HAVE_ATOMIC_32_ADD_AND_FETCH
-- Performing Test HAVE_ATOMIC_32_ADD_AND_FETCH - Failed
-- Performing Test HAVE_ATOMIC_64_ADD_AND_FETCH
-- Performing Test HAVE_ATOMIC_64_ADD_AND_FETCH - Failed
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
libmongoc version (from VERSION_CURRENT file): 3.17.20032601-pre
-- Searching for zlib CMake packages
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
-- Enabling zlib compression (bundled)
-- Looking for include file unistd.h
-- Looking for include file unistd.h - not found
-- Looking for include file stdarg.h
-- Looking for include file stdarg.h - found
-- Searching for compression library zstd
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Not found
-- Check size of socklen_t
-- Check size of socklen_t - done
-- Looking for sched_getcpu
-- Looking for sched_getcpu - not found
-- Searching for compression library header snappy-c.h
-- Not found (specify -DCMAKE_INCLUDE_PATH=/path/to/snappy/include for Snappy compression)
-- No ICU library found, SASLPrep disabled for SCRAM-SHA-256 authentication.
-- If ICU is installed in a non-standard directory, define ICU_ROOT as the ICU installation path.
Searching for libmongocrypt
-- libmongocrypt not found. Configuring without Client-Side Field Level Encryption support.
-- Performing Test MONGOC_HAVE_SS_FAMILY
-- Performing Test MONGOC_HAVE_SS_FAMILY - Failed
-- Compiling against Secure Channel
-- Compiling against Windows SSPI
-- Building with MONGODB-AWS auth support
-- Build files generated for:
-- build system: Visual Studio 16 2019
-- instance: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Git/mongo-c-driver/cmake-build
---------------------------------------------------------
C:\Git\mongo-c-driver\cmake-build>msbuild.exe /p:Configuration=RelWithDebInfo ALL_BUILD.vcxproj
运行上面的命令 : msbuild.exe /p.. 以下是输出 ;
用于 .NET Framework 的 Microsoft (R) 生成引擎版本 16.6.0+5ff7b0c9e
版权所有(C) Microsoft Corporation。保留所有权利。
生成启动时间为 2020-07-02 09:34:12。
节点 1 上的项目“C:\Git\mongo-c-driver\cmake-build\ALL_BUILD.vcxproj”(默认目标)。
项目“C:\Git\mongo-c-driver\cmake-build\ALL_BUILD.vcxproj”(1)正在节点 1 上生成“C:\Git\mongo-c-driver\cmake-build\ZERO_CHECK.vcxpr
oj”(2) (默认目标)。
PrepareForBuild:
正在创建目录“x64\RelWithDebInfo\ZERO_CHECK\”。
正在创建目录“x64\RelWithDebInfo\ZERO_CHECK\ZERO_CHECK.tlog\”。
InitializeBuildStatus:
正在创建“x64\RelWithDebInfo\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild”,因为已指定“AlwaysCreate”。
CustomBuild:
Checking Build System
FinalizeBuildStatus:
正在删除文件“x64\RelWithDebInfo\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild”。
正在对“x64\RelWithDebInfo\ZERO_CHECK\ZERO_CHECK.tlog\ZERO_CHECK.lastbuildstate”执行 Touch 任务。
已完成生成项目“C:\Git\mongo-c-driver\cmake-build\ZERO_CHECK.vcxproj”(默认目标)的操作。
项目“C:\Git\mongo-c-driver\cmake-build\ALL_BUILD.vcxproj”(1)正在节点 1 上生成“C:\Git\mongo-c-driver\cmake-build\src\libmongoc\ag
gregation1.vcxproj”(3) (默认目标)。
项目“C:\Git\mongo-c-driver\cmake-build\src\libmongoc\aggregation1.vcxproj”(3)正在节点 1 上生成“C:\Git\mongo-c-driver\cmake-build
\src\libbson\bson_shared.vcxproj”(4) (默认目标)。
PrepareForBuild:
正在创建目录“bson_shared.dir\RelWithDebInfo\”。
正在创建目录“C:\Git\mongo-c-driver\cmake-build\src\libbson\RelWithDebInfo\”。
正在创建目录“bson_shared.dir\RelWithDebInfo\bson_shared.tlog\”。
InitializeBuildStatus:
正在创建“bson_shared.dir\RelWithDebInfo\bson_shared.tlog\unsuccessfulbuild”,因为已指定“AlwaysCreate”。
CustomBuild:
Building Custom Rule C:/Git/mongo-c-driver/src/libbson/CMakeLists.txt
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.26.28801\bin\HostX64\x64\CL.exe /c /I
"C:\Git\mongo-c-driver\cmake-build\src\libbson\src" /I"C:\Git\mongo-c-driver\cmake-build\src\libbson\src\bson" /I"C:\
Git\mongo-c-driver\src\libbson\src" /I"C:\Git\mongo-c-driver\src\libbson\..\..\src\common" /Zi /nologo /W3 /WX- /diag
nostics:column /O2 /Ob1 /D WIN32 /D _WINDOWS /D NDEBUG /D BSON_COMPILATION /D JSONSL_PARSE_NAN /D COMMON_PREFIX_=_bso
n_common /D "CMAKE_INTDIR=\"RelWithDebInfo\"" /D bson_shared_EXPORTS /D _WINDLL /D _MBCS /Gm- /MD /GS /fp:precise /Zc
:wchar_t /Zc:forScope /Zc:inline /Fo"bson_shared.dir\RelWithDebInfo\\" /Fd"bson_shared.dir\RelWithDebInfo\vc142.pdb"
/Gd /TC /errorReport:queue "C:\Git\mongo-c-driver\src\libbson\src\bson\bcon.c" "C:\Git\mongo-c-driver\src\libbson\src
\bson\bson.c" "C:\Git\mongo-c-driver\src\libbson\src\bson\bson-atomic.c" "C:\Git\mongo-c-driver\src\libbson\src\bson\
bson-clock.c" "C:\Git\mongo-c-driver\src\libbson\src\bson\bson-context.c" "C:\Git\mongo-c-driver\src\libbson\src\bson
\bson-decimal128.c" "C:\Git\mongo-c-driver\src\libbson\src\bson\bson-error.c" "C:\Git\mongo-c-driver\src\libbson\src\
bson\bson-iso8601.c" "C:\Git\mongo-c-driver\src\libbson\src\bson\bson-iter.c" "C:\Git\mongo-c-driver\src\libbson\src\
bson\bson-json.c" "C:\Git\mongo-c-driver\src\libbson\src\bson\bson-keys.c" "C:\Git\mongo-c-driver\src\libbson\src\bso
n\bson-md5.c" "C:\Git\mongo-c-driver\src\libbson\src\bson\bson-memory.c" "C:\Git\mongo-c-driver\src\libbson\src\bson\
bson-oid.c" "C:\Git\mongo-c-driver\src\libbson\src\bson\bson-reader.c" "C:\Git\mongo-c-driver\src\libbson\src\bson\bs
on-string.c" "C:\Git\mongo-c-driver\src\libbson\src\bson\bson-timegm.c" "C:\Git\mongo-c-driver\src\libbson\src\bson\b
son-utf8.c" "C:\Git\mongo-c-driver\src\libbson\src\bson\bson-value.c" "C:\Git\mongo-c-driver\src\libbson\src\bson\bso
n-version-functions.c" "C:\Git\mongo-c-driver\src\libbson\src\bson\bson-writer.c" "C:\Git\mongo-c-driver\src\libbson\
src\jsonsl\jsonsl.c" "C:\Git\mongo-c-driver\src\common\common-b64.c" "C:\Git\mongo-c-driver\src\common\common-md5.c"
"C:\Git\mongo-c-driver\src\common\common-thread.c"
bcon.c
bson.c
&n

本文详细介绍了在Windows 10环境下使用VS2019搭建MongoDB C驱动的过程,包括git克隆、目录创建、cmake配置、项目生成及编译步骤,并提供了常见警告与错误的解决方案。
最低0.47元/天 解锁文章
1724

被折叠的 条评论
为什么被折叠?



