Supported architectures for the legacy C++ driver
masterThe legacy C++ driver supports the following architectures and operating systems:
- Architectures: x86 and x86-64
- Operating Systems: Linux, macOS, Windows, FreeBSD, and Solaris
repository·master·Indexed 22 days ago
https://github.com/mongodb/mongo-cxx-driverA native interface for C++ applications to interact with MongoDB databases, supporting high-performance data operations. The driver includes the mongocxx and bsoncxx libraries, providing tools for BSON document and array manipulation, as well as a suite of microbenchmarks and project-based examples for integration via CMake or Docker.
The legacy C++ driver supports the following architectures and operating systems:
Before using the driver in production, check its development status and stability.
Always verify the Soversion if your deployment environment requires specific shared object versioning.
| Version | Soversion | Development Stability | Development Status |
| :---------: | :-------------: | :-------------------------: | :----------------: |
| master | N/A | _Do not use in production!_ | Active |
| 4.4.1 | 1 | Ready for Use | Bug Fixes Only |
| 4.4.0 | 1 | Ready for Use | Not Supported |
| 4.3.1 | None | Ready for Use | Not Supported |
| 4.0.0 | None | Ready for Use | Not Supported |The driver follows Semantic Versioning. When choosing a version, consider the development status:
Note on Bug Fixes: Relevant bug fixes are backported from the current major version to the previous major version for one year after a new major version is released.
When using the microbenchmarks suite, keep the following in mind:
inMemory mongod instance.bson_decoding is currently not included in the suite because extended_bson has not yet been added to the C++ driver.BSONBench tests are implemented to mirror the C driver's interpretation of the specification.The driver uses namespaces to manage Application Binary Interface (ABI) compatibility:
mongocxx::v_noabi (unstable) or mongocxx::v1 (stable).mongocxx::document::view) so users can opt-into the latest supported ABI version automatically without changing code.Best Practices for Developers:
mongocxx::example::type).mongocxx::v1::example::type).Incorrect Pattern (Avoid):
namespace mongocxx::v_noabi::example {
// If mongocxx::example::type changes from v_noabi to v1,
// this parameter incorrectly changes type too.
void fn(mongocxx::example::type param);
}Correct Pattern:
namespace mongocxx::v_noabi::example {
// Always resolves to the specific version intended.
void fn(v_noabi::example::type param);
}bsoncxx (for BSON manipulation) and mongocxx (for MongoDB server interaction). These libraries share a similar architectural structure and coding patterns. When reviewing documentation or guidelines, descriptions intended for bsoncxx generally apply to mongocxx as well, unless explicitly stated otherwise.bson package that implements the BSON specification. This package can be used as a standalone library for object serialization and deserialization, even in applications that do not use MongoDB.The driver provides forward headers with the -fwd suffix (e.g., value-fwd.hpp) and a special fwd.hpp in each ABI subdirectory. These headers declare class types and enumerations without defining them, which helps reduce compilation dependencies.
fwd.hpp: Provides all forward declarations for a specific ABI namespace.<name>-fwd.hpp: Provides forward declarations for a specific component.When using the driver, prefer including the forward header when you only need to declare a pointer or reference to a type.
mongocxx::instance is designed to be a singleton-like lifecycle manager. You should not attempt to recreate an instance once one has been destroyed, nor should you attempt to use any driver objects (like mongocxx::client) after the mongocxx::instance has gone out of scope or been destroyed. Doing so will result in undefined behavior or errors.The driver follows a strict policy regarding implicit conversions to prevent ambiguous overloads:
explicit: Any single-argument constructor or User-Defined Conversion Function (UDCF) should be marked explicit by default.implicit: You may only use implicit conversions sparingly if:std::string to std::string_view).T to std::optional<T>).To maintain consistency with the driver's error handling pattern, follow these rules for declaring error codes:
errc enumeration as a nested enum inside that class. Implement a static error_category() member function within that same class.exception.hpp), declare the errc enumeration at the namespace scope and implement error_category() as a free function.The bsoncxx and mongocxx libraries are organized into three main functional directories: include/, lib/, and test/.
include/<library>/: Contains public headers installed to the prefix.v<N> (stable ABI) must not include headers from v_noabi (unstable ABI) or older v<N> versions.v_noabi are placed under an extra <library>/ subdirectory (e.g., include/bsoncxx/v_noabi/bsoncxx/...) to support direct include styles like #include <bsoncxx/document/element.hpp>.lib/<library>/: Contains internal headers and implementation files.private/ contains internal interfaces reusable across ABI components without affecting the ABI.lib/v<abi>/... mirrors the layout of the include directory.test/<library>/: Contains test files that mirror the lib/ layout and can use any ABI component.