我安装并集成了最新版本的 vcpkg:
e:\work\vcpkg>vcpkg version
Vcpkg package management program version 0.0.65-692a363701156f1bc319306fbde93fb6748325f6
See LICENSE.txt for license information.
e:\work\vcpkg>vcpkg integrate install
Applied user-wide integration for this vcpkg root.
All C++ projects can now #include any installed libraries.
Linking will be handled automatically.
Installing new libraries will make them instantly available.
我安装了谷歌测试:
e:\work\vcpkg>vcpkg list
gtest:x64-windows 1.8 GoogleTest and GoogleMock testing frameworks.
gtest:x86-windows 1.8 GoogleTest and GoogleMock testing frameworks.
我gtest.h
在 Visual Studio 2015 Update 3 的项目中包含:
#include <gtest/gtest.h>
它编译得很好,但我有链接器错误:
1>main.obj : error LNK2001: unresolved external symbol "void __cdecl testing::InitGoogleTest(int *,char * *)" (?InitGoogleTest@testing@@YAXPEAHPEAPEAD@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: int __cdecl testing::UnitTest::Run(void)" (?Run@UnitTest@testing@@QEAAHXZ)
1>main.obj : error LNK2001: unresolved external symbol "public: static class testing::UnitTest * __cdecl testing::UnitTest::GetInstance(void)" (?GetInstance@UnitTest@testing@@SAPEAV12@XZ)
显然,Visual Studio 不知道它应该与gtest.lib
. 我不明白为什么。Vcpkg 只说“链接将被自动处理”。不知道它将如何做到这一点。
在我的项目的“附加库依赖项”中,我可以看到这些继承的值:
$(VcpkgRoot)lib
$(VcpkgRoot)lib\manual-link
并$(VcpkgRoot)
决心e:\work\vcpkg\installed\x64-windows\
。所以看起来整合是成功的。但是 Visual Studio 如何知道它应该与gtest.lib
?
请注意,如果我gtest.lib
手动添加到“附加依赖项”,一切正常,并gtest.dll
自动复制到输出目录。