undefined symbol: _ZN6google8protobuf2io20ZeroCopyOutputStream15WriteAliasedRawEPKvi
What version of protobuf and what language are you using? Version: master/v3.6.0/v3.5.0 etc. v3.3.0 Language: C++/Java/Python/C#/Ruby/PHP/Objective-C/Javascript C++ What operating system (Linux, Windows, ...) and version? Linux RHEL 6.7 What runtime / compiler are you using (e.g., python version or gcc version) gcc version 4.8.2 20140120 (Red Hat 4.8.2-15) (GCC) What did you do? Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Linked against static protobuf libs in my DLL. While loading the DLL i am getting undefined symbols error.
What did you expect to see No Undefined symbols
What did you see instead? undefined symbol: _ZN6google8protobuf2io20ZeroCopyOutputStream15WriteAliasedRawEPKvi
Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).
Anything else we should know about your project / environment
Would you please also include your installation steps and how you link the library to your project?
Shifted to static libs from dynamic after that also i am getting below error Include ../../release_v12/lib64/libprotobuf.a undefined symbol: _ZNK6google8protobuf7Message13SpaceUsedLongEv
While Linking with DLL getting following errors
/usr/bin/ld: /usr/local/lib/libprotobuf.a(zero_copy_stream_impl_lite.o): relocation R_X86_64_32S against symbol _ZTVN6google8protobuf2io18CopyingInputStreamE' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(descriptor.o): relocation R_X86_64_32S against symbol _ZTVN6google8protobuf14DescriptorPool14ErrorCollectorE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/lib/libprotobuf.a(descriptor_database.o): relocation R_X86_64_32S against symbol _ZTVN6google8protobuf18DescriptorDatabaseE' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(descriptor.pb.o): relocation R_X86_64_32S against symbol _ZNSs4_Rep20_S_empty_rep_storageE@@GLIBCXX_3.4' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/lib/libprotobuf.a(dynamic_message.o): relocation R_X86_64_32S against symbol _ZTVN6google8protobuf14DynamicMessageE' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(extension_set_heavy.o): relocation R_X86_64_32S against symbol _ZN6google8protobuf15FieldDescriptor17kTypeToCppTypeMapE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/lib/libprotobuf.a(generated_message_reflection.o): relocation R_X86_64_32S against symbol _ZTVN6google8protobuf8internal26GeneratedMessageReflectionE' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(map_field.o): relocation R_X86_64_32 against symbol _ZN6google8protobuf8internal30DeleteMapEntryDefaultInstancesEv' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/lib/libprotobuf.a(message.o): relocation R_X86_64_32S against symbol _ZTVN6google8protobuf10ReflectionE' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(reflection_ops.o): relocation R_X86_64_32 against .rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/lib/libprotobuf.a(substitute.o): relocation R_X86_64_32 against .rodata.str1.8' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(text_format.o): relocation R_X86_64_32S against symbol _ZTVN6google8protobuf10TextFormat6FinderE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/lib/libprotobuf.a(unknown_field_set.o): relocation R_X86_64_32 against .text' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(wire_format.o): relocation R_X86_64_32S against .rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/lib/libprotobuf.a(strtod.o): relocation R_X86_64_32 against .rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(tokenizer.o): relocation R_X86_64_32S against symbol _ZTVN6google8protobuf2io14ErrorCollectorE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/lib/libprotobuf.a(zero_copy_stream_impl.o): relocation R_X86_64_32S against symbol _ZTVN6google8protobuf2io24ConcatenatingInputStreamE' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(atomicops_internals_x86_gcc.o): relocation R_X86_64_32 against .rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/lib/libprotobuf.a(stringprintf.o): relocation R_X86_64_32S against symbol _ZNSs4_Rep20_S_empty_rep_storageE@@GLIBCXX_3.4' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(structurally_valid.o): relocation R_X86_64_32 against .rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/lib/libprotobuf.a(strutil.o): relocation R_X86_64_32 against .rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(extension_set.o): relocation R_X86_64_32S against symbol _ZTVN6google8protobuf8internal15ExtensionFinderE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/lib/libprotobuf.a(any.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
Added -fPIC option in both CPPFLAGS and CXXFLAGS in protobuf and rebuilt. but still facing the same error
You should add
set_property(TARGET libprotobuf-lite PROPERTY POSITION_INDEPENDENT_CODE ON)
to libprotobuf-lite.cmake and set_property(TARGET libprotobuf PROPERTY POSITION_INDEPENDENT_CODE ON) to libprotobuf.cmake, or at least that worked for me. Did you make sure (make VERBOSE=1) that -fPIC was included into gcc cmdline?
On the other hand, since static linking is explicitly allowed with --compile_static_extension setup.py option I would suggest @acozzette to add -fPIC to static libraries as well.
While Linking with DLL getting following errors /usr/bin/ld: /usr/local/lib/libprotobuf.a(zero_copy_stream_impl_lite.o): relocation R_X86_64_32S against symbol
_ZTVN6google8protobuf2io18CopyingInputStreamE' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(descriptor.o): relocation R_X86_64_32S against symbol_ZTVN6google8protobuf14DescriptorPool14ErrorCollectorE' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(descriptor_database.o): relocation R_X86_64_32S against symbol_ZTVN6google8protobuf18DescriptorDatabaseE' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(descriptor.pb.o): relocation R_X86_64_32S against symbol_ZNSs4_Rep20_S_empty_rep_storageE@@GLIBCXX_3.4' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(dynamic_message.o): relocation R_X86_64_32S against symbol_ZTVN6google8protobuf14DynamicMessageE' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(extension_set_heavy.o): relocation R_X86_64_32S against symbol_ZN6google8protobuf15FieldDescriptor17kTypeToCppTypeMapE' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(generated_message_reflection.o): relocation R_X86_64_32S against symbol_ZTVN6google8protobuf8internal26GeneratedMessageReflectionE' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(map_field.o): relocation R_X86_64_32 against symbol_ZN6google8protobuf8internal30DeleteMapEntryDefaultInstancesEv' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(message.o): relocation R_X86_64_32S against symbol_ZTVN6google8protobuf10ReflectionE' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(reflection_ops.o): relocation R_X86_64_32 against.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(substitute.o): relocation R_X86_64_32 against.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(text_format.o): relocation R_X86_64_32S against symbol_ZTVN6google8protobuf10TextFormat6FinderE' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(unknown_field_set.o): relocation R_X86_64_32 against.text' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(wire_format.o): relocation R_X86_64_32S against.rodata' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(strtod.o): relocation R_X86_64_32 against.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(tokenizer.o): relocation R_X86_64_32S against symbol_ZTVN6google8protobuf2io14ErrorCollectorE' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(zero_copy_stream_impl.o): relocation R_X86_64_32S against symbol_ZTVN6google8protobuf2io24ConcatenatingInputStreamE' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(atomicops_internals_x86_gcc.o): relocation R_X86_64_32 against.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(stringprintf.o): relocation R_X86_64_32S against symbol_ZNSs4_Rep20_S_empty_rep_storageE@@GLIBCXX_3.4' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(structurally_valid.o): relocation R_X86_64_32 against.rodata' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(strutil.o): relocation R_X86_64_32 against.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(extension_set.o): relocation R_X86_64_32S against symbol_ZTVN6google8protobuf8internal15ExtensionFinderE' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libprotobuf.a(any.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPICAdded -fPIC option in both CPPFLAGS and CXXFLAGS in protobuf and rebuilt. but still facing the same error
./configure CFLAGS="-fPIC" CXXFLAGS="-fPIC" Using this function can solve my problem.
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.