mongo-c-driver 是一个用 C 编写的 MongoDB 客户端库。
mongo-c-driver 依赖于 Libbson <https://github.com/mongodb/libbson>
。如果没有在您的系统上安装,Libbson 将会自动构建。
如果正在寻找传统的 C 驱动器,它可以在 Legacy 分支 <https://github.com/mongodb/mongo-c-driver/tree/legacy>
中找到。
文档在 http://api.mongodb.org/c/current/ 上可用。有关 libmongoc 的问题,或反馈,请查看我们的 支持渠道 <https://mongodb.ac.cn/about/support>
。请不要直接发送任何有关 libmongoc 的电子邮件给开发者,您更有可能通过 Google Groups 上的 mongodb-user 列表
获得答复。
认为您找到了一个错误?希望看到 libmongoc 中的新功能?请在我们的问题跟踪工具 JIRA 中打开一个案例。
创建账号并登录 <https://jira.mongodb.org>
_.CDRIVER 项目 <https://jira.mongodb.org/browse/CDRIVER>
。所有驱动器项目(例如 CDRIVER、CSHARP、JAVA)和核心服务器项目(例如 SERVER)的问题报告在 JIRA 上都是 公开的。
如果您在阅读下面的说明后仍有困难构建驱动器,请通过 mongodb-user 列表
发送电子邮件寻求帮助。请确保在您的电子邮件中包含以下所有信息
./autogen.sh
或 ./configure
的输出(取决于您是从源代码检出还是从 tarball 构建)。从 "libbson 用以下选项配置" 开始的输出就足够了。未能包含相关信息将导致额外的往返通信来确认必要的细节,从而延迟有用的响应。以下是一个虚构的帮助请求示例,其中提供了相关信息
你好,我正在尝试使用SSL构建C驱动,从mongo-c-driver-1.1.11.tar.gz。我在Ubuntu 14.04,64位英特尔系统上,使用gcc 4.8.2。我是这样运行配置的:
$ ./configure --enable-sasl=yes
checking for gcc... gcc
checking whether the C compiler works... yes
... SNIPPED OUTPUT, but when you ask for help, include full output without any omissions ...
checking for pkg-config... no
checking for SASL... no
checking for sasl_client_init in -lsasl2... no
checking for sasl_client_init in -lsasl... no
configure: error: You must install the Cyrus SASL libraries and development headers to enable SASL support.
你能告诉我需要安装什么吗?谢谢!
.. _mongodb-user list: http://groups.google.com/group/mongodb-user
如果你在驱动程序或任何其他MongoDB项目中发现了安全漏洞,请根据以下说明报告,请在此处生成漏洞报告 <http://docs.mongodb.org/manual/tutorial/create-a-vulnerability-report>
_。
除非你打算为mongo-c-driver做出贡献,否则你将想要从发布包构建。
最新版本是1.1.11,你可以从这里下载。mongo-c-driver-1.1.11.tar.gz <https://github.com/mongodb/mongo-c-driver/releases/download/1.1.11/mongo-c-driver-1.1.11.tar.gz>
_。
在UNIX-like系统上构建,请按照以下步骤操作:
$ tar xzf mongo-c-driver-1.1.11.tar.gz $ cd mongo-c-driver-1.1.11 $ ./configure $ make $ sudo make install
要查看配置期间可用的所有选项,请运行:
$ ./configure --help
在Windows Vista或更高版本上使用Visual Studio 2010构建,请按照以下步骤操作:
cd mongo-c-driver-1.1.11 cd src\libbson cmake -DCMAKE_INSTALL_PREFIX=C:\usr -G "Visual Studio 10 Win64" . msbuild.exe ALL_BUILD.vcxproj msbuild.exe INSTALL.vcxproj cd .... cmake -DCMAKE_INSTALL_PREFIX=C:\usr -DBSON_ROOT_DIR=C:\usr -G "Visual Studio 10 Win64" . msbuild.exe ALL_BUILD.vcxproj msbuild.exe INSTALL.vcxproj
mongo-c-driver包含libbson的副本,以防你的系统尚未安装libbson。配置脚本将检测libbson是否未安装,并将其安装。
Fedora:
$ sudo yum install git gcc automake autoconf libtool
Debian:
$ sudo apt-get install git gcc automake autoconf libtool
FreeBSD:
$ su -c 'pkg install git gcc automake autoconf libtool'
你可以使用以下命令检出并构建mongo-c-driver:
git clone https://github.com/mongodb/mongo-c-driver.git cd mongo-c-driver ./autogen.sh make sudo make install
在标准automake风格的脚本中,./autogen.sh只需要运行一次。你可以直接使用./configure。同时,请参阅./configure --help以获取所有配置选项。
目前,mongo-c-driver的cmake构建系统没有构建libbson包。这需要使用cmake手动进行。
通过使用OpenSSL支持SSL。SASL目前不支持,但计划支持。要启用OpenSSL支持,从此处 <http://slproweb.com/products/Win32OpenSSL.html>
_安装适当的OpenSSL for Windows。下面的说明假设64位构建,因此你需要为"Win64 OpenSSL 1.0.1f"获取版本,该版本包括库和头文件。
如果你是从git构建,而不是从发布包,还需要初始化libbson的git子模块:
git submodule init git submodule update
然后使用cmake和Visual Studio的命令行工具msbuild.exe进行libbson的构建和安装。当然,你也可以从Visual Studio打开这些项目文件:
转到 src\libbson 目录,执行 cmake 命令:-DCMAKE_INSTALL_PREFIX=C:\usr -G "Visual Studio 10 Win64" . msbuild.exe ALL_BUILD.vcxproj msbuild.exe INSTALL.vcxproj 然后转到 ... 目录,再次执行:cmake -DCMAKE_INSTALL_PREFIX=C:\usr -DBSON_ROOT_DIR=C:\usr -G "Visual Studio 10 Win64" . msbuild.exe ALL_BUILD.vcxproj msbuild.exe INSTALL.vcxproj
要生成文档,您需要安装 :code:yelp-tools
软件包。在 Linux 下,这个软件包可以在您的发行版的包管理器中找到,在 MacOS 下,我们推荐使用 TingPing 的 homebrew-gnome tap <https://github.com/TingPing/homebrew-gnome>
。
然后使用以下 :code:./configure
选项:
--enable-html-docs
- 构建HTML文档--enable-man-pages
- 构建 и 安装手册页面