Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
107 lines (65 sloc) 2.63 KB
.. include:: /includes/unicode-checkmark.rst
================
MongoDB C Driver
================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: twocols
Introduction
------------
The MongoDB C Driver, also known as “libmongoc”, is the official client library
for C applications, and provides a base for MongoDB drivers in higher-level
languages.
The library is compatible with all major platforms. It depends on libbson
to create and parse BSON data.
- `Tutorial <http://mongoc.org/libmongoc/current/tutorial.html>`__
- `Usage Guide <http://mongoc.org/libmongoc/current/index.html>`__
- `API Reference <http://mongoc.org/libmongoc/current/api.html>`_
- `Changelog <https://github.com/mongodb/mongo-c-driver/releases>`__
- `Source Code <https://github.com/mongodb/mongo-c-driver>`__
Installation
------------
See `Installing the MongoDB C Driver (libmongoc) and BSON library (libbson)
<http://mongoc.org/libmongoc/current/installing.html>`__.
Connect to MongoDB Atlas
------------------------
To connect to a `MongoDB Atlas <https://docs.atlas.mongodb.com/>`_ cluster, use the `Atlas connection string <https://docs.atlas.mongodb.com/driver-connection>`__ for your cluster:
.. code-block:: c
#include <mongoc/mongoc.h>
int
main (int argc, char *argv[])
{
mongoc_database_t *database;
mongoc_client_t *client;
mongoc_init ();
client = mongoc_client_new(
"mongodb+srv://<username>:<password>@<cluster-url>/test?retryWrites=true"
);
database = mongoc_client_get_database (client, "test");
mongoc_database_destroy (database);
mongoc_client_destroy (client);
mongoc_cleanup ();
return 0;
}
See `Advanced Connections <http://mongoc.org/libmongoc/current/advanced-connections.html>`__
for more ways to connect.
Compatibility
-------------
MongoDB Compatibility
~~~~~~~~~~~~~~~~~~~~~
.. include:: /includes/extracts/c-driver-compatibility-matrix-mongodb.rst
.. include:: /includes/mongodb-compatibility-table-c.rst
.. include:: /includes/older-server-versions-unsupported.rst
Language Compatibility
~~~~~~~~~~~~~~~~~~~~~~
.. include:: /includes/extracts/c-driver-compatibility-matrix-language.rst
.. include:: /includes/language-compatibility-table-c.rst
How to get help
---------------
- Join our `Google Group <http://groups.google.com/group/mongodb-user>`__.
- Ask on `Stack Overflow <http://stackoverflow.com/questions/tagged/mongodb-c>`__.
- Visit our `Support Channels <http://www.mongodb.org/about/support>`__.
- File a bug or feature request on `JIRA <https://jira.mongodb.org/browse/CDRIVER>`__.
You can’t perform that action at this time.