Navigation

    MongoDB C++ Driver

    The MongoDB C++ Driver is the official client library for C++ applications using the C++11 (or later) standard.

    See Installing the mongocxx driver.

    To connect to a MongoDB Atlas cluster, use the Atlas connection string for your cluster:

    #include <mongocxx/client.hpp>
    #include <mongocxx/instance.hpp>
    //...
    mongocxx::instance inst{}; // This should be done only once.
    mongocxx::client conn{
    mongocxx::uri{
    "mongodb+srv://<username>:<password>@<cluster-url>/test?retryWrites=true&w=majority"
    }
    };
    mongocxx::database db = conn["test"];
    C++ Driver VersionMongoDB 4.4MongoDB 4.2MongoDB 4.0MongoDB 3.6MongoDB 3.4MongoDB 3.2MongoDB 3.0MongoDB 2.6MongoDB 2.4
    mongocxx 3.6
    mongocxx 3.5
    mongocxx 3.4
    mongocxx 3.3
    mongocxx 3.2
    mongocxx 3.1
    mongocxx 3.0

    The driver does not support older versions of MongoDB.

    C++ Driver VersionC++03C++11C++14
    mongocxx-3.x
    legacy-1.x

    For more information on how to read the compatibility tables, see our guide on MongoDB Compatibility Tables.

    Give Feedback