https://github.com/mongodb-developer/get-started-c
Getting started with the MongoDB C driver connecting to MongoDB Atlas
https://github.com/mongodb-developer/get-started-c
Last synced: 3 months ago
JSON representation
Getting started with the MongoDB C driver connecting to MongoDB Atlas
- Host: GitHub
- URL: https://github.com/mongodb-developer/get-started-c
- Owner: mongodb-developer
- License: apache-2.0
- Created: 2023-03-13T18:15:23.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-13T10:06:24.000Z (over 1 year ago)
- Last Synced: 2025-03-22T13:51:27.321Z (3 months ago)
- Language: C
- Homepage:
- Size: 26.4 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Getting Started with the MongoDB C Driver
Some simple examples using the [MongoDB C driver](https://www.mongodb.com/docs/drivers/c/)
## Build and run
These examples are built using GCC on macOS, but they should compile anywhere that has a C compiler
- Clone this repo
- Edit the file called `URI.h` and add your [MongoDB Connection String](https://www.mongodb.com/basics/mongodb-connection-string) inside the quotes:
```c
// URI.h
#define MY_MONGODB_URI "mongodb+srv://"
```- Make the build script executable `chmod a+x build-all.sh`
- `./build-all.sh`### Build and run with CMake
We can also use CMake to build the programs in this repo. After editing the `URI.h`, run below commands in the directory:
```c
mkdir build
cd build
cmake ..
cmake --build .
```In macOS you need to install Xcode first (free on the Mac App Store)