ich installiert und integriert neueste Version von vcpkg:vcpkg funktioniert nicht für Google Test
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.
ich google Test installiert:
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.
I enthalten gtest.h
in meinem Projekt in Visual Studio 2015 Update 3 :
#include <gtest/gtest.h>
Es kompiliert in Ordnung, aber ich habe Fehler Linker:
1>main.obj : error LNK2001: unresolved external symbol "void __cdecl testing::InitGoogleTest(int *,char * *)" ([email protected]@@[email protected])
1>main.obj : error LNK2001: unresolved external symbol "public: int __cdecl testing::UnitTest::Run(void)" ([email protected]@[email protected]@QEAAHXZ)
1>main.obj : error LNK2001: unresolved external symbol "public: static class testing::UnitTest * __cdecl testing::UnitTest::GetInstance(void)" ([email protected]@[email protected]@[email protected])
Offenbar weiß Visual Studio nicht, dass es mit gtest.lib
verknüpfen sollte. Und ich kann nicht verstehen warum. Vcpkg sagt nur, dass "Linking automatisch behandelt wird". Keine Ahnung, wie es das machen wird.
In „Weitere Bibliothek Abhängigkeiten“ von meinem Projekt kann ich diese vererbten Werte sehen:
$(VcpkgRoot)lib
$(VcpkgRoot)lib\manual-link
Und $(VcpkgRoot)
-e:\work\vcpkg\installed\x64-windows\
behoben ist. Es scheint also, als ob die Integration erfolgreich war. Aber wie Visual Studio weiß, sollte es mit gtest.lib
verknüpfen?
Beachten Sie, dass, wenn ich manuell gtest.lib
zu "Zusätzliche Abhängigkeiten" hinzufügen, alles funktioniert und gtest.dll
automatisch in Ausgabeverzeichnis kopiert wird.
Also die empfohlene Möglichkeit, 'gtest' zu verlinken, ist wie ich es tat: füge es tatsächlich zu" Additional Dependencies "hinzu, richtig? – Mikhail
Ja, ich denke schon. – traversaro