Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests fail to link when compiling as a DLL with Visual C++ #3420

Closed
florin-crisan opened this issue May 28, 2021 · 3 comments
Closed

Tests fail to link when compiling as a DLL with Visual C++ #3420

florin-crisan opened this issue May 28, 2021 · 3 comments
Labels

Comments

@florin-crisan
Copy link
Contributor

Describe the bug

When compiling with Visual C++ 2015 or 2017 and CMake and the CMake flag BUILD_SHARED_LIBS is set to ON, you get the following linker errors:

googletest-printers-test.cc.obj : error LNK2019: unresolved external symbol "void __cdecl testing::internal::PrintTo(char16_t const *,class std::basic_ostream<char,struct std::char_traits<char> > *)" (?PrintTo@internal@testing@@YAXPEB_SPEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z) referenced in function "public: static void __cdecl testing::internal::UniversalPrinter<char16_t const *>::Print(char16_t const * const &,class std::basic_ostream<char,struct std::char_traits<char> > *)" (?Print@?$UniversalPrinter@PEB_S@internal@testing@@SAXAEBQEB_SPEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)
googletest-printers-test.cc.obj : error LNK2019: unresolved external symbol "void __cdecl testing::internal::PrintTo(char32_t const *,class std::basic_ostream<char,struct std::char_traits<char> > *)" (?PrintTo@internal@testing@@YAXPEB_UPEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z) referenced in function "public: static void __cdecl testing::internal::UniversalPrinter<char32_t const *>::Print(char32_t const * const &,class std::basic_ostream<char,struct std::char_traits<char> > *)" (?Print@?$UniversalPrinter@PEB_U@internal@testing@@SAXAEBQEB_UPEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)
googletest-param-test-test.cc.obj : error LNK2019: unresolved external symbol "public: __cdecl testing::internal::MarkAsIgnored::MarkAsIgnored(char const *)" (??0MarkAsIgnored@internal@testing@@QEAA@PEBD@Z) referenced in function "void __cdecl works_here::`dynamic initializer for 'gtest_allow_ignore_NotInstantiatedTest''(void)" (??__Egtest_allow_ignore_NotInstantiatedTest@works_here@@YAXXZ)

Steps to reproduce the bug

Run the developer command prompt for Visual C++ 2015 or 2017 and type the following commands:

cmake -S <source directory> -B <build directory> -G Ninja -D CMAKE_BUILD_TYPE=Debug -D gtest_build_tests=ON -D gtest_build_samples=ON -D BUILD_GMOCK=ON -D BUILD_SHARED_LIBS=ON

cmake --build <build directory>

Does the bug persist in the most recent commit?

Yes

What operating system and version are you using?

Microsoft Windows [Version 10.0.19042.985]

What compiler and version are you using?

Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1
Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27045

What build system are you using?

cmake version 3.20.2

Additional context

@florin-crisan
Copy link
Contributor Author

Working on a fix.

@florin-crisan
Copy link
Contributor Author

Created pull request #3421 but can't seem to figure out how to link it to this issue.

@florin-crisan
Copy link
Contributor Author

Closing issue as fix was merged into master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants