---
name: "mongoc_init"
section: "3"
platform: "linux"
package: "libmongoc-doc"
version: "1.30.4-1+deb13u3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/mongoc_init"
---

# mongoc\_init(3)

## SYNOPSIS

```
void
mongoc_init (void);
```

## DESCRIPTION

Initialize the MongoDB C Driver by calling *mongoc\_init()* exactly once at the beginning of your program. It is responsible for initializing global state such as process counters, SSL, and threading primitives.

Exception to this is **mongoc\_log\_set\_handler()**, which should be called before **mongoc\_init()** or some log traces would not use your log handling function. See *Custom Log Handlers* for a detailed example.

Call *mongoc\_cleanup()* exactly once at the end of your program to release all memory and other resources allocated by the driver. You must not call any other MongoDB C Driver functions after *mongoc\_cleanup()*. Note that *mongoc\_init()* does **not** reinitialize the driver after *mongoc\_cleanup()*.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
