Skip to content

Commit 6925e53

Browse files
DOSCP-43051 Get Started landing and Install (#32)
1 parent 3aefd14 commit 6925e53

9 files changed

+299
-12
lines changed

snooty.toml

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
name = "c"
22
title = "C Driver"
33

4-
intersphinx = [ "https://www.mongodb.com/docs/manual/objects.inv",
5-
"https://www.mongodb.com/docs/atlas/objects.inv",
6-
"https://www.mongodb.com/docs/drivers/objects.inv",
7-
]
8-
9-
toc_landing_pages = [
10-
"/read"
4+
intersphinx = [
5+
"https://www.mongodb.com/docs/manual/objects.inv",
6+
"https://www.mongodb.com/docs/atlas/objects.inv",
7+
"https://www.mongodb.com/docs/drivers/objects.inv",
118
]
9+
10+
toc_landing_pages = ["/read", "/get-started"]
1211
sharedinclude_root = "https://raw.githubusercontent.com/10gen/docs-shared/main/"
1312

1413
[constants]
@@ -26,3 +25,5 @@ driver-short = "C driver"
2625
language = "C"
2726
mdb-server = "MongoDB Server"
2827
stable-api = "Stable API"
28+
libmongoc = "libmongoc"
29+
libbson = "libbson"

source/get-started.txt

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
.. _c-get-started:
2+
3+
=============================
4+
Get Started with the {+driver-short+}
5+
=============================
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 2
11+
:class: singlecol
12+
13+
.. facet::
14+
:name: genre
15+
:values: tutorial
16+
17+
.. meta::
18+
:description: Learn how to create an app to connect to MongoDB deployment by using the C driver.
19+
:keywords: quick start, tutorial, basics
20+
21+
.. toctree::
22+
23+
/get-started/download-and-install/
24+
/get-started/create-a-deployment/
25+
/get-started/create-a-connection-string/
26+
/get-started/connect-to-mongodb/
27+
/get-started/next-steps/
28+
29+
Overview
30+
--------
31+
32+
The {+driver-long+} is a {+language+} library that you can use to connect to MongoDB and
33+
interact with data stored in your deployment. This guide shows you how to create an
34+
application that uses the {+driver-short+} to connect to a MongoDB cluster hosted on
35+
MongoDB Atlas and query data in your cluster.
36+
37+
.. tip::
38+
39+
MongoDB Atlas is a fully managed cloud database service that hosts your MongoDB
40+
deployments. You can create your own free (no credit card required) MongoDB Atlas
41+
deployment by following the steps in this guide.
42+
43+
Follow this guide to connect a sample {+language+} application to a MongoDB Atlas
44+
deployment. If you prefer to connect to MongoDB using a different driver or
45+
programming language, see our :driver:`list of official drivers <>`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.. _c-get-started-connect-to-mongodb:
2+
3+
==================
4+
Connect to MongoDB
5+
==================
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.. _c-get-started-connection-string:
2+
3+
==========================
4+
Create a Connection String
5+
==========================
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.. _c-get-started-create-deployment:
2+
3+
===========================
4+
Create a MongoDB Deployment
5+
===========================
+215
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
.. _c-get-started-download-and-install:
2+
3+
====================
4+
Download and Install
5+
====================
6+
7+
Download the {+driver-short+}
8+
----------------------
9+
10+
The {+driver-short+} consists of two libraries: ``libbson`` and
11+
``libmongoc``. In this guide, you will learn how to install ``libmongoc``,
12+
which comes bundled with ``libbson``.
13+
14+
You can install the {+driver-short+} by using
15+
a package manager, or by installing the libraries from source. Different Linux
16+
distributions install different versions of the driver when installed with a
17+
package manager. Because of this, you should check the version your distribution
18+
includes before installing the driver.
19+
20+
On RedHat Enterprise Linux (RHEL) distributions, you can check the version by
21+
running the following command in your shell:
22+
23+
.. code-block:: bash
24+
25+
sudo dnf info mongo-c-driver-devel
26+
27+
On Debian-based distributions, you can check the version by running the
28+
following command in your shell:
29+
30+
.. code-block:: bash
31+
32+
apt-cache policy libmongoc-dev
33+
34+
If the version of the driver that is available is not the version you want, you
35+
can install the driver from source.
36+
.. TODO: To learn how to install the driver from source, see the c-install-from-source guide.
37+
38+
To learn how to install the driver by using a package manager, select the tab corresponding to
39+
your operating system:
40+
41+
.. tabs::
42+
43+
.. tab:: Linux
44+
:tabid: install-linux
45+
46+
.. _c-redhat-install:
47+
48+
RedHat Enterprise Linux Distributions
49+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50+
51+
You can install the driver on RedHat Enterprise Linux (RHEL)
52+
distributions, version 7 or later, or distributions based on RHEL,
53+
such as:
54+
55+
- `CentOS <https://www.centos.org/>`__
56+
- `Rocky Linux <https://rockylinux.org/>`__
57+
- `AlmaLinux <https://almalinux.org/>`__
58+
59+
Before you install the driver on a RHEL distribution, not including
60+
Fedora, you must first enable the Extra Packages for Enterprise
61+
Linux (EPEL) repository. You can enable the EPEL repository by
62+
installing the ``epel-release`` package, as shown in the following
63+
example:
64+
65+
.. code-block:: bash
66+
67+
yum install epel-release
68+
69+
Then, you can install the {+driver-short+}
70+
by using ``yum``. To do so, run the following command in
71+
your shell:
72+
73+
.. code-block:: bash
74+
75+
yum install mongo-c-driver-devel
76+
77+
.. note:: Developer Packages
78+
79+
The preceding code example installs the developer packages, which
80+
are required to build applications that use the {+driver-short+}. To
81+
install only the libraries, without development files, run the
82+
following command:
83+
84+
.. code-block:: bash
85+
86+
yum install mongo-c-driver
87+
88+
If you are installing on a RHEL distribution that is version 8 or
89+
later, we recommend running the preceding code examples by using
90+
``dnf`` instead of ``yum``.
91+
92+
Fedora
93+
~~~~~~
94+
95+
If you are using Fedora or an enterprise Linux distribution of
96+
version 8 or later, you can install the driver by using the same
97+
commands as shown in the :ref:`preceding example <c-redhat-install>`
98+
and replacing ``yum`` with ``dnf``.
99+
100+
The following example shows how to install the {+driver-short+} in a
101+
Fedora distribution:
102+
103+
.. code-block:: bash
104+
105+
dnf install mongo-c-driver-devel
106+
107+
Debian-Based Distributions
108+
~~~~~~~~~~~~~~~~~~~~~~~~~~
109+
110+
In Debian-Based Linux distributions, including Ubuntu and Ubuntu
111+
derivatives, the driver libraries are available through the Advanced
112+
Packaging Tool (APT). You can install the driver with APT by running
113+
the following command in your shell:
114+
115+
.. code-block:: bash
116+
117+
apt install libmongoc-dev
118+
119+
The preceding code example installs the developer packages, which
120+
are required to build applications that use the {+driver-short+}. To
121+
install only the libraries, without development files, run the
122+
following command:
123+
124+
.. code-block:: bash
125+
126+
apt install libmongoc-1.0-0
127+
128+
.. tab:: Windows
129+
:tabid: install-windows
130+
131+
For Windows environments, we recommend building the {+driver-short+}
132+
libraries from source to ensure maximum compatibility with the local
133+
toolchain. You can automate building from source by using a
134+
from-source library package management tool, such as
135+
`vcpkg <https://vcpkg.io>`__.
136+
137+
.. tip::
138+
139+
To learn how to get started with vcpkg, see the `vcpkg Get Started
140+
guide <https://learn.microsoft.com/en-us/vcpkg/get_started/overview>`__
141+
in the Microsoft documentation.
142+
143+
In `vcpkg manifest mode <https://learn.microsoft.com/en-us/vcpkg/users/manifests>`__, add the
144+
driver library to your project's ``vcpkg.json`` manifest file,
145+
as shown in the following example:
146+
147+
.. code-block:: js
148+
149+
{
150+
// ...
151+
"dependencies": [
152+
// ...
153+
"mongo-c-driver"
154+
]
155+
}
156+
157+
When you build a CMake project with vcpkg integration and have a
158+
``vcpkg.json`` manifest file, vcpkg automatically installs the project's
159+
dependencies before proceeding with configuration.
160+
161+
If you are using `vcpkg classic mode <https://learn.microsoft.com/en-us/vcpkg/users/classic-mode>`__,
162+
you can install the driver by running the following command in
163+
your shell:
164+
165+
.. code-block:: bash
166+
167+
vcpkg install mongo-c-driver
168+
169+
After you install the driver, the standard CMake configuration file
170+
is available, as well as the generated ``IMPORTED`` targets. You can
171+
create a ``CMakeLists.txt`` file as shown in the following example:
172+
173+
.. code-block:: cmake
174+
175+
find_package(mongoc-1.0 CONFIG REQUIRED)
176+
target_link_libraries(my-application
177+
PRIVATE $<IF:$<TARGET_EXISTS:mongo::mongoc_shared>,mongo::mongoc_shared,mongo::mongoc_static>)
178+
179+
.. note::
180+
181+
You can use the ``$<IF:$<TARGET_EXISTS...>:...>`` generator
182+
expression in the preceding example to switch the link type of
183+
``libmongoc`` based on the form that is available from the
184+
``find_package()`` command. ``libmongoc`` supports building with
185+
both *dynamic* and *static* library types, but vcpkg
186+
installs only one type at a time.
187+
188+
To configure the CMake project with vcpkg integration, set the CMake
189+
toolchain file in the configuration command by running the following
190+
commands in your shell:
191+
192+
.. code-block:: bash
193+
194+
cmake -S . -B _build -D
195+
CMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake
196+
197+
.. tab:: MacOS
198+
:tabid: install-mac
199+
200+
You can download the {+driver-short+} on MacOS by using the `Homebrew
201+
package manager <https://brew.sh/>`__. To do so, run the following command in
202+
your shell:
203+
204+
.. code-block:: bash
205+
206+
brew install mongo-c-driver
207+
208+
.. TODO:
209+
.. To learn how to install the driver libraries from source, see the
210+
.. :ref:`c-install-from-source`` guide.
211+
212+
After you complete these steps, you have the {+driver-short+} installed
213+
on your machine.
214+
215+
.. include:: /includes/get-started/troubleshoot.rst

source/get-started/next-steps.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.. _c-get-started-next-steps:
2+
3+
==========
4+
Next Steps
5+
==========
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.. note::
2+
3+
If you run into issues on this step, ask for help in the
4+
:community-forum:`MongoDB Community Forums <tag/c/>`
5+
or submit feedback by using the :guilabel:`Rate this page`
6+
tab on the right or bottom right side of this page.

source/index.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
:titlesonly:
77
:maxdepth: 1
88

9+
/get-started
910
/databases-collections
1011
/read
1112
libbson API Documentation <{+api-libbson+}>
@@ -21,12 +22,11 @@ the official MongoDB driver for {+language+} applications.
2122
.. ``libmongoc`` depends on the ``libbson`` library. To learn more about ``libbson``, see
2223
.. <BSON guide link>.
2324

24-
.. TODO
25-
.. Get Started
26-
.. -----------
25+
Get Started
26+
-----------
2727

28-
.. Learn how to install the driver, establish a connection to MongoDB, and begin
29-
.. working with data in the :ref:`c-get-started` tutorial.
28+
Learn how to install the driver, establish a connection to MongoDB, and begin
29+
working with data in the :ref:`c-get-started` tutorial.
3030

3131
.. TODO
3232
.. Connect to MongoDB

0 commit comments

Comments
 (0)