protocolbuffers / protobuf

Protocol Buffers - Google's data interchange format
http://protobuf.dev
Other
65.68k stars 15.5k forks source link

failed linkage when trying to build librotobuf with esp-idf #17780

Open Dimandragon opened 3 months ago

Dimandragon commented 3 months ago

I tried downloading protobuf c++ releases 3.15.2, 3.16.0 and 3.19.6, and create static library using files listed for libprotobuf and libprotobuf-lite targets (from cmake/libprotobuf-lite.cmake and cmake/libprotobuf.cmake) and adding "src" folder to include path using cmake in my esp-idf project using components api (should give result similar to creating static library)

When i use option optimize_for = LITE_RUNTIME; in the proto file there is no any problems

But withno this option I get the following linker error in all listed versions:

/home/dmitry/.espressif/tools/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/12.2.0/../../../xtensa-esp32s3-elf/bin/ld: esp-idf/protobuf/libprotobuf.a(wire_format.cc.obj):(.literal._ZN6google8protobuf8internal10WireFormat27_InternalParseAndMergeFieldEPNS0_7MessageEPKcPNS1_12ParseContextEyPKNS0_10ReflectionEPKNS0_15FieldDescriptorE+0x8): undefined reference to _ZNK6google8protobuf10Reflection28MutableRepeatedFieldInternalIiEEPNS0_13RepeatedFieldIT_EEPNS0_7MessageEPKNS0_15FieldDescriptorE' /home/dmitry/.espressif/tools/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-es p32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/12.2.0/../../../../xtensa-esp32s3-elf/bin/ld: esp-idf/protobuf/libprotobuf.a(wire_format.cc.obj):(.literal._ZN6google8protobuf8internal10WireFormat22InternalSerializeFieldEPKNS0_15FieldDescriptorERKNS0_7MessageEPhPNS0_2io19EpsCopyOutputStreamE+0xc): undefined reference to_ZNK6google8protobuf10Reflection24GetRepeatedFieldInternalIiEERKNS0_13RepeatedFieldIT_EERKNS0_7MessageEPKNS0_15FieldDescriptorE' /home/dmitry/.espressif/tools/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa- esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/12.2.0/../../../../xtensa-esp32s3-elf/bin/ld: esp-idf/protobuf/libprotobuf.a(wire_format.cc.obj): in function _ZN6google8protobuf8internal10WireFormat27_InternalParseAndMergeFieldEPNS0_7MessageEPKcPNS1_12ParseContextEyPKNS0_10ReflectionEPKNS0_15FieldDescriptorE': /home/dmitry/projects/smart-glove/components/protobuf/src/google/protobuf/wire_format.cc :862: undefined reference to_ZNK6google8protobuf10Reflection28MutableRepeatedFieldInternalIiEEPNS0_13RepeatedFieldIT_EEPNS0_7MessageEPKNS0_15FieldDescriptorE' /home/dmitry/.espressif/tools/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-es p32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/12.2.0/../../../../xtensa-esp32s3-elf/bin/ld: esp-idf/protobuf/libprotobuf.a(wire_format.cc.obj): in function _ZN6google8protobuf2io19EpsCopyOutputStream15UnsafeWriteSizeEmPh': /home/dmitry/projects/smart-glove/components/protobuf/src/google/protobuf/io/coded_stream.h:947: undefined reference to_ZNK6google8protobuf10Reflection24GetRepeatedFieldInternalI iEERKNS0_13RepeatedFieldIT_EERKNS0_7MessageEPKNS0_15FieldDescriptorE'

What could I have missed? There is my cmake file to protobuf component version 3.19.6, for other versions i've used simular to this one, but using SRCS list from cmake/libprotobuf-lite.cmake and cmake/libprotobuf.cmake files of other versions

idf_component_register(SRCS
  "src/google/protobuf/any_lite.cc"
  "src/google/protobuf/arena.cc"
  "src/google/protobuf/arenastring.cc"
  "src/google/protobuf/extension_set.cc"
  "src/google/protobuf/generated_enum_util.cc"
  "src/google/protobuf/generated_message_table_driven_lite.cc"
  "src/google/protobuf/generated_message_tctable_lite.cc"
  "src/google/protobuf/generated_message_util.cc"
  "src/google/protobuf/implicit_weak_message.cc"
  "src/google/protobuf/inlined_string_field.cc"
  "src/google/protobuf/io/coded_stream.cc"
  "src/google/protobuf/io/io_win32.cc"
  "src/google/protobuf/io/strtod.cc"
  "src/google/protobuf/io/zero_copy_stream.cc"
  "src/google/protobuf/io/zero_copy_stream_impl.cc"
  "src/google/protobuf/io/zero_copy_stream_impl_lite.cc"
  "src/google/protobuf/map.cc"
  "src/google/protobuf/message_lite.cc"
  "src/google/protobuf/parse_context.cc"
  "src/google/protobuf/repeated_field.cc"
  "src/google/protobuf/repeated_ptr_field.cc"
  "src/google/protobuf/stubs/bytestream.cc"
  "src/google/protobuf/stubs/common.cc"
  "src/google/protobuf/stubs/int128.cc"
  "src/google/protobuf/stubs/status.cc"
  "src/google/protobuf/stubs/statusor.cc"
  "src/google/protobuf/stubs/stringpiece.cc"
  "src/google/protobuf/stubs/stringprintf.cc"
  "src/google/protobuf/stubs/structurally_valid.cc"
  "src/google/protobuf/stubs/strutil.cc"
  "src/google/protobuf/stubs/time.cc"
  "src/google/protobuf/wire_format_lite.cc"
  "src/google/protobuf/any.cc"
  "src/google/protobuf/any.pb.cc"
  "src/google/protobuf/api.pb.cc"
  "src/google/protobuf/compiler/importer.cc"
  "src/google/protobuf/compiler/parser.cc"
  "src/google/protobuf/descriptor.cc"
  "src/google/protobuf/descriptor.pb.cc"
  "src/google/protobuf/descriptor_database.cc"
  "src/google/protobuf/duration.pb.cc"
  "src/google/protobuf/dynamic_message.cc"
  "src/google/protobuf/empty.pb.cc"
  "src/google/protobuf/extension_set_heavy.cc"
  "src/google/protobuf/field_mask.pb.cc"
  "src/google/protobuf/generated_message_bases.cc"
  "src/google/protobuf/generated_message_reflection.cc"
  "src/google/protobuf/generated_message_table_driven.cc"
  "src/google/protobuf/generated_message_tctable_full.cc"
  "src/google/protobuf/io/gzip_stream.cc"
  "src/google/protobuf/io/printer.cc"
  "src/google/protobuf/io/tokenizer.cc"
  "src/google/protobuf/map_field.cc"
  "src/google/protobuf/message.cc"
  "src/google/protobuf/reflection_ops.cc"
  "src/google/protobuf/service.cc"
  "src/google/protobuf/source_context.pb.cc"
  "src/google/protobuf/struct.pb.cc"
  "src/google/protobuf/stubs/substitute.cc"
  "src/google/protobuf/text_format.cc"
  "src/google/protobuf/timestamp.pb.cc"
  "src/google/protobuf/type.pb.cc"
  "src/google/protobuf/unknown_field_set.cc"
  "src/google/protobuf/util/delimited_message_util.cc"
  "src/google/protobuf/util/field_comparator.cc"
  "src/google/protobuf/util/field_mask_util.cc"
  "src/google/protobuf/util/internal/datapiece.cc"
  "src/google/protobuf/util/internal/default_value_objectwriter.cc"
  "src/google/protobuf/util/internal/error_listener.cc"
  "src/google/protobuf/util/internal/field_mask_utility.cc"
  "src/google/protobuf/util/internal/json_escaping.cc"
  "src/google/protobuf/util/internal/json_objectwriter.cc"
  "src/google/protobuf/util/internal/json_stream_parser.cc"
  "src/google/protobuf/util/internal/object_writer.cc"
  "src/google/protobuf/util/internal/proto_writer.cc"
  "src/google/protobuf/util/internal/protostream_objectsource.cc"
  "src/google/protobuf/util/internal/protostream_objectwriter.cc"
  "src/google/protobuf/util/internal/type_info.cc"
  "src/google/protobuf/util/internal/utility.cc"
  "src/google/protobuf/util/json_util.cc"
  "src/google/protobuf/util/message_differencer.cc"
  "src/google/protobuf/util/time_util.cc"
  "src/google/protobuf/util/type_resolver_util.cc"
  "src/google/protobuf/wire_format.cc"
  "src/google/protobuf/wrappers.pb.cc"
                    INCLUDE_DIRS "src"
                    REQUIRES pthread)

set_target_properties(${COMPONENT_LIB} PROPERTIES COMPILE_FLAGS "-Wno-maybe-uninitialized -DHAVE_PTHREAD -Wno-format")

set_source_files_properties("src/google/protobuf/arena.cc"
    PROPERTIES COMPILE_FLAGS
    -Wno-missing-field-initializers
)
github-actions[bot] commented 12 hours 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 add a comment.

This issue is labeled inactive because the last activity was over 90 days ago. This issue will be closed and archived after 14 additional days without activity.