How do I use mongoDB driver with C++ in Visual Studio 2022 vcpkg

3 weeks ago 26
ARTICLE AD BOX

I'm having issues with Visual Studio not finding the mongocxx library. I've used vcpkg to install the driver and integrate it with Visual Studio. Steps I took include:

git clone https://github.com/microsoft/vcpkg.git cd .\vcpkg .\bootstrap-vcpkg.bat .\vcpkg integrate install .\vcpkg install mongo-cxx-driver

Then going into Visual studio I try to use the library:

#include <mongocxx/v_noabi/mongocxx/instance.hpp>

(As for some reason mongocxx/instance.hpp doesn't show up as an option.)

Then I am met with these errors:

Severity Code Description Project File Line Suppression State Details Error (active) E1696 cannot open source file "mongocxx/instance-fwd.hpp" CS499-DatabaseEnhancement-BlakeAllen C:\Users\issyr\vcpkg\installed\x64-windows\include\mongocxx\v_noabi\mongocxx\instance.hpp 19 Error (active) E1696 cannot open source file "mongocxx/logger-fwd.hpp" CS499-DatabaseEnhancement-BlakeAllen C:\Users\issyr\vcpkg\installed\x64-windows\include\mongocxx\v_noabi\mongocxx\instance.hpp 20 Error (active) E1696 cannot open source file "mongocxx/config/prelude.hpp" CS499-DatabaseEnhancement-BlakeAllen C:\Users\issyr\vcpkg\installed\x64-windows\include\mongocxx\v_noabi\mongocxx\instance.hpp 22 Error (active) E1696 cannot open source file "mongocxx/config/postlude.hpp" CS499-DatabaseEnhancement-BlakeAllen C:\Users\issyr\vcpkg\installed\x64-windows\include\mongocxx\v_noabi\mongocxx\instance.hpp 138

I've been trying to get the driver to work for days now and no resources available online are helping.

Read Entire Article