使用通过 vcpkg 安装的库时出现 LNK2019 错误

LNK2019 error when using a library installed with vcpkg

我已经使用正确的三元组 vcpkg 安装了库:

C:\Users\***>vcpkg list libnoise
libnoise:x64-windows              1.0.0       A general-purpose library that generates three-d...

然后我执行了以下命令:

C:\Users\***>vcpkg integrate install
Applied user-wide integration for this vcpkg root.

All MSBuild C++ projects can now #include any installed libraries.
Linking will be handled automatically.
Installing new libraries will make them instantly available.

CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=C:/Windows/vcpkg/scripts/buildsystems/vcpkg.cmake"

但是在我的 Visual Studio 2019 项目中,有一个 x64 项目,只有 headers 被成功集成:

#include <noise/noise.h> // The header is found as well as the definition of noise::module::Perlin

int main()
{
   noise::module::Perlin noise; // The implementation is not found
}

尝试编译时,我得到:

1>------ Build started: Project: Mayak, Configuration: Debug x64 ------
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl noise::module::Perlin::Perlin(void)" (__imp_??0Perlin@module@noise@@QEAA@XZ) referenced in function main
1>NoiseVideoGenerator.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl noise::module::Perlin::Perlin(void)" (__imp_??0Perlin@module@noise@@QEAA@XZ)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl noise::module::Perlin::~Perlin(void)" (__imp_??1Perlin@module@noise@@UEAA@XZ) referenced in function main
1>NoiseVideoGenerator.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl noise::module::Perlin::~Perlin(void)" (__imp_??1Perlin@module@noise@@UEAA@XZ)
1>C:\Users\sylva\source\repos\Mayak\x64\Debug\Mayak.exe : fatal error LNK1120: 2 unresolved externals
1>Done building project "Mayak.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

附带说明一下,我已经查找了噪声库的 .lib 文件的名称,并尝试将它们添加到链接器 > 输入属性中,但仍然不起作用。

我做错了什么?

要启用自动链接,select您当前的项目并转到属性。 (Alt-Enter) 确保编辑正确的配置。然后转到 Configuration Properties -> vcpkg 并确保 AutoLink 已启用。

它已被开发人员修复,在 GitHub : https://github.com/microsoft/vcpkg/issues/14127