Skip to content

MSVC may link error when using protobuf built with C++17 but build otel-cpp with C++20 #3799

@owent

Description

@owent

Describe your environment

Platform: Windows 11
Compiler: Visual Studio 2026 (v143 latest: v14.44(17.14))

Package:

  • Protobuf: v31.1 ( Compiling with c++17 standard )
  • abseil-cpp: 20250512.1 ( Compiling with c++17 standard )
  • otel-cpp: v1.24.0 ( Compiling with c++20 standard )

Steps to reproduce

Build package as above.

What is the expected behavior?

Build success

What is the actual behavior?

31>  pc-distributed-transaction-protocol.vcxproj -> D:\workspace\git\github\atframework\atsf4g-co\build_jobs_cmake_tools\publish\bin\Debug\pc-distributed-transaction-protocol.dll
32>  server_frame-config.vcxproj -> D:\workspace\git\github\atframework\atsf4g-co\build_jobs_cmake_tools\publish\bin\Debug\server_frame-config.dll
30>  pp-gamesvr-protocol.vcxproj -> D:\workspace\git\github\atframework\atsf4g-co\build_jobs_cmake_tools\publish\bin\Debug\pp-gamesvr-protocol.dll
33>------ Build started: Project: server_frame, Configuration: Debug x64 ------
33>     Creating library D:/workspace/git/github/atframework/atsf4g-co/build_jobs_cmake_tools/publish/lib/e6f3a084/lib/Debug/server_frame.lib and object D:/workspace/git/github/atframework/atsf4g-co/build_jobs_cmake_tools/publish/lib/e6f3a084/lib/Debug/server_frame.exp
33>opentelemetry_proto.lib(metrics_service.pb.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl google::protobuf::internal::ArenaStringPtr::ArenaStringPtr(class google::protobuf::internal::GlobalEmptyStringConstexpr const *,struct google::protobuf::internal::ConstantInitialized)" (__imp_??0ArenaStringPtr@internal@protobuf@google@@QEAA@PEBVGlobalEmptyStringConstexpr@123@UConstantInitialized@123@@Z)
33>opentelemetry_proto.lib(common.pb.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl google::protobuf::internal::ArenaStringPtr::ArenaStringPtr(class google::protobuf::internal::GlobalEmptyStringConstexpr const *,struct google::protobuf::internal::ConstantInitialized)" (__imp_??0ArenaStringPtr@internal@protobuf@google@@QEAA@PEBVGlobalEmptyStringConstexpr@123@UConstantInitialized@123@@Z)
33>opentelemetry_proto.lib(metrics.pb.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl google::protobuf::internal::ArenaStringPtr::ArenaStringPtr(class google::protobuf::internal::GlobalEmptyStringConstexpr const *,struct google::protobuf::internal::ConstantInitialized)" (__imp_??0ArenaStringPtr@internal@protobuf@google@@QEAA@PEBVGlobalEmptyStringConstexpr@123@UConstantInitialized@123@@Z)
33>opentelemetry_proto.lib(trace.pb.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl google::protobuf::internal::ArenaStringPtr::ArenaStringPtr(class google::protobuf::internal::GlobalEmptyStringConstexpr const *,struct google::protobuf::internal::ConstantInitialized)" (__imp_??0ArenaStringPtr@internal@protobuf@google@@QEAA@PEBVGlobalEmptyStringConstexpr@123@UConstantInitialized@123@@Z)
33>opentelemetry_proto.lib(trace_service.pb.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl google::protobuf::internal::ArenaStringPtr::ArenaStringPtr(class google::protobuf::internal::GlobalEmptyStringConstexpr const *,struct google::protobuf::internal::ConstantInitialized)" (__imp_??0ArenaStringPtr@internal@protobuf@google@@QEAA@PEBVGlobalEmptyStringConstexpr@123@UConstantInitialized@123@@Z)
33>opentelemetry_proto.lib(logs.pb.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl google::protobuf::internal::ArenaStringPtr::ArenaStringPtr(class google::protobuf::internal::GlobalEmptyStringConstexpr const *,struct google::protobuf::internal::ConstantInitialized)" (__imp_??0ArenaStringPtr@internal@protobuf@google@@QEAA@PEBVGlobalEmptyStringConstexpr@123@UConstantInitialized@123@@Z)
33>opentelemetry_proto.lib(logs_service.pb.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl google::protobuf::internal::ArenaStringPtr::ArenaStringPtr(class google::protobuf::internal::GlobalEmptyStringConstexpr const *,struct google::protobuf::internal::ConstantInitialized)" (__imp_??0ArenaStringPtr@internal@protobuf@google@@QEAA@PEBVGlobalEmptyStringConstexpr@123@UConstantInitialized@123@@Z)
33>    Hint on symbols that are defined and could potentially match:
33>      "__declspec(dllimport) public: __cdecl google::protobuf::internal::ArenaStringPtr::ArenaStringPtr(class google::protobuf::Arena *)" (__imp_??0ArenaStringPtr@internal@protobuf@google@@QEAA@PEAVArena@23@@Z)
33>      "__declspec(dllimport) public: __cdecl google::protobuf::internal::ArenaStringPtr::ArenaStringPtr(class google::protobuf::Arena *,struct google::protobuf::internal::ArenaStringPtr const &)" (__imp_??0ArenaStringPtr@internal@protobuf@google@@QEAA@PEAVArena@23@AEBU0123@@Z)
33>opentelemetry_proto.lib(metrics_service.pb.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) class google::protobuf::internal::GlobalEmptyStringConstexpr const google::protobuf::internal::fixed_address_empty_string" (__imp_?fixed_address_empty_string@internal@protobuf@google@@3VGlobalEmptyStringConstexpr@123@B)
33>opentelemetry_proto.lib(common.pb.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) class google::protobuf::internal::GlobalEmptyStringConstexpr const google::protobuf::internal::fixed_address_empty_string" (__imp_?fixed_address_empty_string@internal@protobuf@google@@3VGlobalEmptyStringConstexpr@123@B)
33>opentelemetry_proto.lib(metrics.pb.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) class google::protobuf::internal::GlobalEmptyStringConstexpr const google::protobuf::internal::fixed_address_empty_string" (__imp_?fixed_address_empty_string@internal@protobuf@google@@3VGlobalEmptyStringConstexpr@123@B)
33>opentelemetry_proto.lib(trace.pb.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) class google::protobuf::internal::GlobalEmptyStringConstexpr const google::protobuf::internal::fixed_address_empty_string" (__imp_?fixed_address_empty_string@internal@protobuf@google@@3VGlobalEmptyStringConstexpr@123@B)
33>opentelemetry_proto.lib(trace_service.pb.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) class google::protobuf::internal::GlobalEmptyStringConstexpr const google::protobuf::internal::fixed_address_empty_string" (__imp_?fixed_address_empty_string@internal@protobuf@google@@3VGlobalEmptyStringConstexpr@123@B)
33>opentelemetry_proto.lib(logs.pb.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) class google::protobuf::internal::GlobalEmptyStringConstexpr const google::protobuf::internal::fixed_address_empty_string" (__imp_?fixed_address_empty_string@internal@protobuf@google@@3VGlobalEmptyStringConstexpr@123@B)
33>opentelemetry_proto.lib(logs_service.pb.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) class google::protobuf::internal::GlobalEmptyStringConstexpr const google::protobuf::internal::fixed_address_empty_string" (__imp_?fixed_address_empty_string@internal@protobuf@google@@3VGlobalEmptyStringConstexpr@123@B)
33>D:\workspace\git\github\atframework\atsf4g-co\build_jobs_cmake_tools\publish\bin\Debug\server_frame.dll : fatal error LNK1120: 2 unresolved externals
34>------ Build started: Project: loginsvr, Configuration: Debug x64 ------

Additional context

Protobuf v31-v33 will have different ABI in C++17 and C++20, we should force the generated .pb.cc files be compiled as the same c++ standard as protobuf.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingneeds-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions