0

In the cmake file for my project, I include googletest as a dependency using git submodules. This works fine. When I then also add dependencies through vcpkg (for example Boost), I get the following linker error:

LNK2001 unresolved external symbol
"class testing::internal::Mutex testing::internal::g_linked_ptr_mutex" (?g_linked_ptr_mutex@internal@testing@@3VMutex@12@A)

Wouter
  • 538
  • 6
  • 15

1 Answers1

0

This is caused by a conflicting version of GoogleTest in your vcpkg installation. Certain libraries will cause the entire vcpkg include directory to be included in your project. If you have previously installed gtest/gmock in vcpkg, this version can be accidentally brought into scope by including a different package.

The easiest way to resolve this is to remove the vcpkg version of gtest:

vcpkg remove gtest gmock

You might have to repeat this command for different platform targets. Alternatively, you can also remove the submodule and use the vcpkg version of gtest.

Wouter
  • 538
  • 6
  • 15