Protobuf doesn't build using CMake on Windows
Version: main/v25.1.0 Language: C++ OS: Windows 11
Steps to reproduce the behavior:
- git clone https://github.com/protocolbuffers/protobuf
- cd protobuf
- git submodule update --init --recursive
- mkdir .build
- cd .build
- cmake ..
This build fails. For simplicity of seeing the settings, I opened it in CMake-GUI, and click Configure, and select Visual Studio 2022. I check the "ABSL_PROPAGATE_CXX_STD" to remove a warning. protobuf_BUILD_TESTS is checked by default, and this generates a lot of errors. When I uncheck this, with the settings below, I still get the remaining linker errors as shown below.
CMake settings:
Visual Studio linker errors:
Severity Code Description Project File Line Suppression State Details Error LNK2005 "void __cdecl absl::lts_20230802::base_internal::SetCurrentThreadIdentity(struct absl::lts_20230802::base_internal::ThreadIdentity ,void (__cdecl)(void *))" (?SetCurrentThreadIdentity@base_internal@lts_20230802@absl@@YAXPEAUThreadIdentity@123@P6AXPEAX@Z@Z) already defined in abseil_dll.lib(abseil_dll.dll) protoc C:\protobuf\protobuf.build\absl_base.lib(thread_identity.obj) 1
Severity Code Description Project File Line Suppression State Details Error LNK2005 "void __cdecl absl::lts_20230802::base_internal::ClearCurrentThreadIdentity(void)" (?ClearCurrentThreadIdentity@base_internal@lts_20230802@absl@@YAXXZ) already defined in abseil_dll.lib(abseil_dll.dll) protoc C:\protobuf\protobuf.build\absl_base.lib(thread_identity.obj) 1
Severity Code Description Project File Line Suppression State Details Error LNK1169 one or more multiply defined symbols found protoc C:\protobuf\protobuf.build\Debug\protoc.exe 1
If you enable protobuf_BUILD_SHARED_LIBS does it work? It looks like somehow you're in a mixed state where it's linking in both the absl dll and the statically linked libraries...
https://github.com/protocolbuffers/protobuf/assets/13501663/d7af6c11-d801-471d-bc14-c8bb233268cd
It got closer, but still had one linker error, video of the build shown here after doing a clean git clone and submodule update.
Note: gRPC gives clear warnings about statically linking it vs using a DLL, so I may prefer to use a static library if possible. I believe these issues should be reproducible and fix-able? (fingers crossed)
Correction: I guess it wasn't a linker error, some other compiler error.
hmm that's odd, I have seen that error before and we do set /bigobj in some of our tests config (see here). It looks like it's failing to build descriptor_unittest.cc, so disabling protobuf_BUILD_TESTS might get around this.
FWIW neither of these "fixes" should be necessary. We build with both static and dynamic linkage on windows, and we always build tests. Our CI basically does your reproduction steps, so I'm not sure what the issue could be here. In our closest build we use:
-Dprotobuf_WITH_ZLIB=OFF -Dprotobuf_BUILD_CONFORMANCE=OFF
-Dprotobuf_BUILD_SHARED_LIBS=OFF -Dprotobuf_BUILD_EXAMPLES=ON
What version of MSVC are you using?
I'm able to reproduce the /bigobj error on main, so I can fix that one. As a workaround just don't build our tests? I'm still not sure what the original issue is though, it really seems like you're both statically and dynamically linking Abseil.
Can you provide the full CLI reproduction steps? Following the ones you gave worked fine except for the /bigobj error building our test suite
See video below for CLI repro. Note that I first tracked this down because I was trying to build the gRPC repo which uses protobuf, and it was generating protobuf build errors. So I'm not sure if I would have control over the settings when building protobuf while building gRPC.
https://github.com/protocolbuffers/protobuf/assets/13501663/8284e04f-1a4a-42aa-93d7-53333905fb5b
The Visual Studio errors are copied below:
Severity Code Description Project File Line Suppression State Details Error LNK2005 "void __cdecl absl::lts_20230802::base_internal::SetCurrentThreadIdentity(struct absl::lts_20230802::base_internal::ThreadIdentity ,void (__cdecl)(void *))" (?SetCurrentThreadIdentity@base_internal@lts_20230802@absl@@YAXPEAUThreadIdentity@123@P6AXPEAX@Z@Z) already defined in abseil_dll.lib(abseil_dll.dll) protoc C:\protobufBug\protobuf.build\absl_base.lib(thread_identity.obj) 1 Error LNK2005 "void __cdecl absl::lts_20230802::base_internal::ClearCurrentThreadIdentity(void)" (?ClearCurrentThreadIdentity@base_internal@lts_20230802@absl@@YAXXZ) already defined in abseil_dll.lib(abseil_dll.dll) protoc C:\protobufBug\protobuf.build\absl_base.lib(thread_identity.obj) 1 Error LNK1169 one or more multiply defined symbols found protoc C:\protobufBug\protobuf.build\Debug\protoc.exe 1 Error MSB8066 Custom build for 'C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\map_lite_unittest.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_import_lite.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_import_public_lite.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_lite.pb.h.rule;C:\protobufBug\protobuf\CMakeLists.txt' exited with code 9009. libtest_common_lite C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets 254 Error MSB8066 Custom build for 'C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\any_test.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\map_proto2_unittest.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\map_proto3_unittest.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\map_unittest.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_arena.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_custom_options.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_drop_unknown_fields.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_embed_optimize_for.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_empty.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_enormous_descriptor.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_features.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_import.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_import_public.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_invalid_features.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_lazy_dependencies.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_lazy_dependencies_custom_option.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_lazy_dependencies_enum.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_lite_imports_nonlite.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_mset.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_mset_wire_format.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_no_field_presence.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_no_generic_services.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_optimize_for.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_preserve_unknown_enum.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_preserve_unknown_enum2.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_proto3.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_proto3_arena.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_proto3_arena_lite.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_proto3_bad_macros.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_proto3_lite.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_proto3_optional.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_retention.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\d7bcaec5699f87b42ced304a766c6f3a\unittest_well_known_types.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\210e41e35f94bc5180b0699ec3108022\test_bad_identifiers.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\210e41e35f94bc5180b0699ec3108022\test_large_enum_value.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\11d84603e71cac6c189110887397f52b\json_format.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\11d84603e71cac6c189110887397f52b\json_format_proto3.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\11d84603e71cac6c189110887397f52b\message_differencer_unittest.pb.h.rule;C:\protobufBug\protobuf.build\CMakeFiles\11d84603e71cac6c189110887397f52b\message_differencer_unittest_proto3.pb.h.rule;C:\protobufBug\protobuf\CMakeLists.txt' exited with code 9009. libtest_common C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets 254 Error C1083 Cannot open include file: 'google/protobuf/map_lite_unittest.pb.h': No such file or directory lite-test C:\protobufBug\protobuf\src\google\protobuf\map_lite_test_util.h 11 Error C1083 Cannot open include file: 'google/protobuf/any_test.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\any_test.cc 11 Error C1083 Cannot open include file: 'google/protobuf/unittest_features.pb.h': No such file or directory test_plugin C:\protobufBug\protobuf\src\google\protobuf\compiler\mock_code_generator.h 20 Error C1083 Cannot open include file: 'google/protobuf/map_lite_unittest.pb.h': No such file or directory lite-test C:\protobufBug\protobuf\src\google\protobuf\map_lite_test_util.h 11 Error C1083 Cannot open include file: 'google/protobuf/map_lite_unittest.pb.h': No such file or directory test_plugin C:\protobufBug\protobuf\src\google\protobuf\map_lite_test_util.h 11 Error C1083 Cannot open include file: 'google/protobuf/unittest_lite.pb.h': No such file or directory test_plugin C:\protobufBug\protobuf\src\google\protobuf\test_util_lite.h 15 Error C1083 Cannot open include file: 'google/protobuf/map_lite_unittest.pb.h': No such file or directory fake_plugin C:\protobufBug\protobuf\src\google\protobuf\map_lite_test_util.h 11 Error C1083 Cannot open include file: 'google/protobuf/unittest_lite.pb.h': No such file or directory fake_plugin C:\protobufBug\protobuf\src\google\protobuf\test_util_lite.h 15 Error C1083 Cannot open include file: 'google/protobuf/map_lite_unittest.pb.h': No such file or directory lite-test C:\protobufBug\protobuf\src\google\protobuf\map_lite_test_util.h 11 Error C1083 Cannot open include file: 'google/protobuf/unittest_lite.pb.h': No such file or directory lite-test C:\protobufBug\protobuf\src\google\protobuf\test_util_lite.h 15 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\test_util.h 15 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory test_plugin C:\protobufBug\protobuf\src\google\protobuf\test_util.h 15 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory fake_plugin C:\protobufBug\protobuf\src\google\protobuf\test_util.h 15 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\descriptor_unittest.cc 56 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\descriptor_visitor_test.cc 16 Error C1083 Cannot open include file: 'google/protobuf/unittest_drop_unknown_fields.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\drop_unknown_fields_test.cc 13 Error C1083 Cannot open include file: 'google/protobuf/unittest_features.pb.h': No such file or directory test_plugin C:\protobufBug\protobuf\src\google\protobuf\compiler\mock_code_generator.h 20 Error C1083 Cannot open include file: 'google/protobuf/unittest_features.pb.h': No such file or directory fake_plugin C:\protobufBug\protobuf\src\google\protobuf\compiler\mock_code_generator.h 20 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\test_util.h 15 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\test_util.h 15 Error C1083 Cannot open include file: 'google/protobuf/unittest_custom_options.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\feature_resolver_test.cc 30 Error C1083 Cannot open include file: 'google/protobuf/map_unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\map_test_util.h 11 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\generated_message_tctable_lite_test.cc 14 Error C1083 Cannot open include file: 'google/protobuf/map_unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\internal_message_util_unittest.cc 12 Error C1083 Cannot open include file: 'google/protobuf/map_unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\map_test_util.h 11 Error C1083 Cannot open include file: 'google/protobuf/map_proto2_unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\map_test.cc 24 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\message_unittest.cc 12 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\no_field_presence_test.cc 13 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\preserve_unknown_enum_test.cc 11 Error C1083 Cannot open include file: 'google/protobuf/unittest_proto3_arena.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\proto3_arena_lite_unittest.cc 14 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\test_util.h 15 Error C1083 Cannot open include file: 'google/protobuf/unittest_proto3.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\proto3_lite_unittest.cc 8 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\redaction_metric_test.cc 19 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\test_util.h 15 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\test_util.h 15 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\repeated_field_unittest.cc 46 Error C1083 Cannot open include file: 'google/protobuf/unittest_retention.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\retention_test.cc 22 Error C1083 Cannot open include file: 'google/protobuf/map_unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\text_format_unittest.cc 42 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\test_util.h 15 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\unredacted_debug_format_for_test_test.cc 5 Error C1083 Cannot open include file: 'google/protobuf/unittest_well_known_types.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\well_known_types_unittest.cc 11 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\wire_format_unittest.cc 14 Error C1083 Cannot open include file: 'google/protobuf/unittest_features.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\compiler\code_generator_unittest.cc 26 Error C1083 Cannot open include file: 'google/protobuf/unittest_features.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\compiler\command_line_interface_unittest.cc 23 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\compiler\cpp\arena_ctor_visibility_test.cc 11 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\test_util.h 15 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\compiler\cpp\file_unittest.cc 18 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\compiler\cpp\message_size_unittest.cc 12 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\test_util.h 15 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\test_util.h 15 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\compiler\parser_unittest.cc 32 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\test_util.h 15 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\util\field_comparator_test.cc 16 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\test_util.h 15 Error C1083 Cannot open include file: 'google/protobuf/any_test.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\util\message_differencer_unittest.cc 31 Error C1083 Cannot open include file: 'google/protobuf/util/json_format_proto3.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\util\type_resolver_util_test.cc 25 Error C1083 Cannot open include file: 'google/protobuf/map_lite_unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\map_lite_test_util.h 11 Error C1083 Cannot open include file: 'google/protobuf/unittest_lite.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\test_util_lite.h 15 Error C1083 Cannot open include file: 'google/protobuf/unittest.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\test_util.h 15 Error C1083 Cannot open include file: 'google/protobuf/unittest_features.pb.h': No such file or directory tests C:\protobufBug\protobuf\src\google\protobuf\compiler\mock_code_generator.h 20
I'm able to reproduce the
/bigobjerror on main, so I can fix that one. As a workaround just don't build our tests? I'm still not sure what the original issue is though, it really seems like you're both statically and dynamically linking Abseil.
I'm a "me too" on the /bigobj issue. Freshly cloned repo this AM with no modifications. Setting option(protobuf_BUILD_TESTS "Build tests" OFF) did work around it for me,
@embeddetech Was this something that was working for you but then stopped, or are you like me: a first time compiler of protobuf with VS 2022? If it's the former I'd be interested to known any info as to when there was a previous known good revision.
Yea that's the same thing I did, and I can't reproduce your linker error. Can you check if you have Abseil installed on your machine? That shouldn't matter, but the error message you're getting points to the Abseil dll which shouldn't even get generated by our default cmake build
@simonmcqueen I've used protobuf indirectly using Paho MQTT library and did run into some issues, but I can't remember how I worked around it. So consider me a first time user.
@mkruskal-google I don't have Abseil installed, I'm running on Windows and just did git submodule update --init --recursive to get abseil.
Sorry for slow response, came down with Covid.
What if you explicitly set BUILD_SHARED_LIBS=OFF and protobuf_BUILD_SHARED_LIBS=OFF? This kindof sounds like its trying to link the dll target statically... We've seen ODR violations from that kind of thing in the past
Hmm so actually, I took a look at our CI and we're seeing a lot of warnings like:
cordz_handle.cc.obj : warning LNK4197: export '??_7CordzHandle@cord_internal@lts_20230802@absl@@6B@' specified multiple times; using first specification
cordz_info.cc.obj : warning LNK4197: export '??_7CordzHandle@cord_internal@lts_20230802@absl@@6B@' specified multiple times; using first specification
I wonder if these are related and just present differently in different versions of MSVC?
@mkruskal-google I will also add, I tried following the instructions of /cmake/README.md in the repository, and these instructions also seem problematic.
I think the main issue that I came across was in line 126, it provides the following to generate the build system:
C:\Path\to\build\protobuf> cmake -S. -Bcmake-out
-DCMAKE_INSTALL_PREFIX=/tmp/protobuf
-DCMAKE_CXX_STANDARD=14
-Dprotobuf_ABSL_PROVIDER=package
-DCMAKE_PREFIX_PATH=/tmp/absl # Path to where I installed Abseil
However the C:\Path\to\build\protobuf is expected to be the build folder, but "-S." is speciifed, meaning that is the source folder, and there is no CMakeLists.txt file in that folder (because it's the build folder). I am successfully building Abseil and I appear to have it installed properly (built it in Visual Studio, then built the INSTALL project for Abseil and it appeared to put the lib and include files and folders where I expected.)
Hi @mkruskal-google, Just checking in on this. Has anything been fixed, should I try again? I believe I need a clean build without requiring a build configuration setting, as I am pulling this in as a dependency of other libraries using git submodule update --init. Ideally it should "just work", right? Otherwise, that library should be responsible for properly configuring protobuf as its dependency? Protobuf is at the bottom of a diamond dependency, and causes a lot of issues if it doesn't build properly, I think.
This issue would support the argument for #12787 to be completed.
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.
This issue is labeled inactive because the last activity was over 90 days ago.
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.
This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.