Banjolicious
Banjolicious

Reputation: 33

Visual Studio 2019 and vcpkg packages

Using vcpkg I installed the mongo-cxx-drive:x64-windows I have run vcpkg integrate install When I try to include one of the headers in my project code, Visual Studio can't find it

#include <mongocxx/client.hpp>

I expected to find the files at

D:\vcpkg\vcpkg\installed\x64-windows\include\mongocxx

In this case, I'm finding them at

D:\vcpkg\vcpkg\installed\x64-windows\include\mongocxx\v_noabi\mongocxx

I suspect I'm missing a setting somewhere in Visual Studio, but I'm not having any luck finding it. What do I need to do to allow VS to automatically find the includes for installed libraries?

Upvotes: 0

Views: 32

Answers (1)

Chuck Walbourn
Chuck Walbourn

Reputation: 41127

If your building with MSBuild, then you should add these two statements to your .vcxproj (via a text editor).

Put this after <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />

  <Import Project="D:\vcpkg\vcpkg\scripts\buildsystems\msbuild\vcpkg.props" />
```7

**Put this after `<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />`**
```

Otherwise run vcpkg integrate install.

See Microsoft Learn

Note that when using MSBuild integration, the only path added to your project is include and for link it uses lib\*.lib. In CMake, the targets files can be more customized. Blockquote

Upvotes: 0

Related Questions