my-vcpkg-triplets icon indicating copy to clipboard operation
my-vcpkg-triplets copied to clipboard

include error

Open BiliBiliFox opened this issue 10 months ago • 1 comments

When utilizing the gtest library with vcpkg, the standard installation command is quite verbose:

vcpkg.exe install gtest --overlay-triplets=D:\dev\project\3\my-vcpkg-triplets --triplet=x64-win-llvm

To streamline this process, I've implemented some enhancements. Initially, I added the VCPKG_DEFAULT_TRIPLET environment variable to the system and set it as x64-win-llvm, which obviates the need to include --triplet=x64-win-llvm in the command. Subsequently, I established the VCPKG_OVERLAY_TRIPLETS environment variable, directing it to D:\dev\project\3\my-vcpkg-triplets, thereby eliminating the requirement for --overlay-triplets=D:\dev\project\3\my-vcpkg-triplets. Following these adjustments, you can conveniently install the library with just vcpkg install gtest. However, a prevalent challenge surfaces when working within Visual Studio. Preprocessor directives such as #include "gtest/gtest.h" may trigger errors. This discrepancy arises because the library files, generated by vcpkg, are situated in paths like D:\vcpkg\packages\gtest_x64-win-llvm, whereas the customary library path is D:\vcpkg\packages\gtest_x64-windows. It appears there's an issue with the imported library directory. @Neumann-A How can we address this problem?

BiliBiliFox avatar Apr 09 '24 09:04 BiliBiliFox

However, a prevalent challenge surfaces when working within Visual Studio

Number 1 answer here is: a) Use CMake. If you used CMake to generate project files you did something wrong with the triplet selection, ran cmake in an already configured folder or simply forgot to link the target otherwise b) Make sure Visual Studio actually uses that triplet (see the vcpkg property in the property viewer)

c) system includes should use <> instead of "" d) packages is the staging directory. The correct path is (vcpkg_)?installed/.... e) Consider setting VCPKG_DEFAULT_HOST_TRIPLET instead

I mainly see this as an user error. You probably will also fail to use one of the single config triplets like x64-windows-release.

Neumann-A avatar Apr 09 '24 11:04 Neumann-A