Windows: Building unit tests fails with linker errors
Summary
Building the unit tests on Windows fails with a linker error LNK2001: unresolved external symbol "class google::protobuf::internal::ExplicitlyConstructed<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,8> ...
build cmake --build .
MSBuild version 17.9.8+b34f75857 for .NET Framework
Checking Build System
Generating include/caosdb/info/v1/main.pb.cc, include/caosdb/info/v1/main.grpc.pb.cc, include/caosdb/entity/v1/main.pb.cc, include/caosdb/entity/v1/main.grpc.pb.cc, include/caosdb/info/v1/main.pb.h, include/caosdb/info/v1/main.grpc.pb.h, include/caosdb/entity/v1/main.pb.h, include/caosdb/entity/v1/main.grpc.pb.h
Building Custom Rule C:/Code/LinkAhead/linkahead-cpplib/CMakeLists.txt
main.pb.cc
main.grpc.pb.cc
main.pb.cc
main.grpc.pb.cc
Auto build dll exports
Creating library C:/Code/LinkAhead/linkahead-cpplib/build/lib/caosdb_grpc.lib and object C:/Code/LinkAhead/linkahead-cpplib/build/lib/caosdb_grpc.exp
main.pb.cc.obj : error LNK2001: unresolved external symbol "class google::protobuf::internal::ExplicitlyConstructed<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,8> google::protobuf::internal::fixed_address_empty_string" (?fixed_address_empty_string@internal@protobuf@google@@3V?$ExplicitlyConstructed@V?$basic_string@DU?$char_traits@D@std@@V?
$allocator@D@2@@std@@$07@123@A) [C:\Code\LinkAhead\linkahead-cpplib\build\caosdb_grpc.vcxproj]
main.pb.cc.obj : error LNK2001: unresolved external symbol "class google::protobuf::internal::ExplicitlyConstructed<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,8> google::protobuf::internal::fixed_address_empty_string" (?fixed_address_empty_string@internal@protobuf@google@@3V?$ExplicitlyConstructed@V?$basic_string@DU?$char_traits@D@std@@V?
$allocator@D@2@@std@@$07@123@A) [C:\Code\LinkAhead\linkahead-cpplib\build\caosdb_grpc.vcxproj]
main.pb.cc.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl google::protobuf::Message::MergeFrom(class google::protobuf::Message const &)" (?MergeFrom@Message@protobuf@google@@UEAAXAEBV123@@Z) [C:\Code\LinkAhead\linkahead-cpplib\build\caosdb_grpc.vcxproj]
main.pb.cc.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl google::protobuf::Message::MergeFrom(class google::protobuf::Message const &)" (?MergeFrom@Message@protobuf@google@@UEAAXAEBV123@@Z) [C:\Code\LinkAhead\linkahead-cpplib\build\caosdb_grpc.vcxproj]
main.pb.cc.obj : error LNK2001: unresolved external symbol "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl google::protobuf::Message::InitializationErrorString(void)const " (?InitializationErrorString@Message@protobuf@google@@UEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) [C:\Code\LinkAhead\lin
kahead-cpplib\build\caosdb_grpc.vcxproj]
main.pb.cc.obj : error LNK2001: unresolved external symbol "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl google::protobuf::Message::InitializationErrorString(void)const " (?InitializationErrorString@Message@protobuf@google@@UEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) [C:\Code\LinkAhead\lin
kahead-cpplib\build\caosdb_grpc.vcxproj]
main.pb.cc.obj : error LNK2001: unresolved external symbol "public: virtual unsigned __int64 __cdecl google::protobuf::Message::SpaceUsedLong(void)const " (?SpaceUsedLong@Message@protobuf@google@@UEBA_KXZ) [C:\Code\LinkAhead\linkahead-cpplib\build\caosdb_grpc.vcxproj]
main.pb.cc.obj : error LNK2001: unresolved external symbol "public: virtual unsigned __int64 __cdecl google::protobuf::Message::SpaceUsedLong(void)const " (?SpaceUsedLong@Message@protobuf@google@@UEBA_KXZ) [C:\Code\LinkAhead\linkahead-cpplib\build\caosdb_grpc.vcxproj]
main.pb.cc.obj : error LNK2001: unresolved external symbol "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl google::protobuf::Message::GetTypeName(void)const " (?GetTypeName@Message@protobuf@google@@UEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) [C:\Code\LinkAhead\linkahead-cpplib\build\caosdb_g
rpc.vcxproj]
main.pb.cc.obj : error LNK2001: unresolved external symbol "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl google::protobuf::Message::GetTypeName(void)const " (?GetTypeName@Message@protobuf@google@@UEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) [C:\Code\LinkAhead\linkahead-cpplib\build\caosdb_g
rpc.vcxproj]
main.pb.cc.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl google::protobuf::Message::CheckTypeAndMergeFrom(class google::protobuf::MessageLite const &)" (?CheckTypeAndMergeFrom@Message@protobuf@google@@UEAAXAEBVMessageLite@23@@Z) [C:\Code\LinkAhead\linkahead-cpplib\build\caosdb_grpc.vcxproj]
main.pb.cc.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl google::protobuf::Message::CheckTypeAndMergeFrom(class google::protobuf::MessageLite const &)" (?CheckTypeAndMergeFrom@Message@protobuf@google@@UEAAXAEBVMessageLite@23@@Z) [C:\Code\LinkAhead\linkahead-cpplib\build\caosdb_grpc.vcxproj]
Expected Behavior
Building unit tests should not fail
Actual Behavior
Linker errors
Steps to Reproduce the Problem
Please describe, step by step, how others can reproduce the problem. Please try these steps for yourself on a clean system.
cmake -B . -D CMAKE_BUILD_TYPE=Debug ..
cmake --build .
Specifications
- Version: v0.3.0-dev
- Platform: Windows 11, Visual Studio 17.9.6, cmake version 3.26.4
Possible fixes
Add protobuf sources in CMakeLists