2

I have some c++ code that is used by an iOS project. Therefore, I need to have protobuf support for C++ code in iOS.

I have tried this link: https://developers.google.com/cardboard/develop/ios/protobuf , and also this gist: https://gist.github.com/eyeplum/ff0b76f70ca5b8d192cac0b52496433d . However, they both give the following errors:

...
  CXX      google/protobuf/compiler/csharp/csharp_reflection_class.lo
  CXX      google/protobuf/compiler/csharp/csharp_repeated_enum_field.lo
  CXX      google/protobuf/compiler/csharp/csharp_repeated_message_field.lo
  CXX      google/protobuf/compiler/csharp/csharp_repeated_primitive_field.lo
  CXX      google/protobuf/compiler/csharp/csharp_source_generator_base.lo
In file included from google/protobuf/compiler/csharp/csharp_source_generator_base.cc:39:
./google/protobuf/compiler/csharp/csharp_source_generator_base.h:62:25: warning: private field 'descriptor_' is not used [-Wunused-private-field]
  const FileDescriptor* descriptor_;
                        ^
1 warning generated.
  CXX      google/protobuf/compiler/csharp/csharp_wrapper_field.lo
  CXXLD    libprotoc.la
ar: `u' modifier ignored since `D' is the default (see `U')
  CXXLD    protoc
ld: warning: ignoring file ./.libs/libprotobuf.a, building for iOS-armv7 but attempting to link with file built for iOS-armv7
ld: warning: ignoring file /Users/tom/RefCode/protobuf/src/.libs/libprotobuf.a, building for iOS-armv7 but attempting to link with file built for iOS-armv7
ld: warning: ignoring file ./.libs/libprotoc.a, building for iOS-armv7 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
Undefined symbols for architecture armv7:
  "google::protobuf::compiler::objectivec::ObjectiveCGenerator::ObjectiveCGenerator()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::objectivec::ObjectiveCGenerator::~ObjectiveCGenerator()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::CodeGenerator::~CodeGenerator()", referenced from:
      google::protobuf::compiler::js::Generator::~Generator() in main.o
      google::protobuf::compiler::ruby::Generator::~Generator() in main.o
      google::protobuf::compiler::php::Generator::~Generator() in main.o
  "google::protobuf::compiler::CommandLineInterface::AllowPlugins(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::CommandLineInterface::RegisterGenerator(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, google::protobuf::compiler::CodeGenerator*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::CommandLineInterface::Run(int, char const* const*)", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::CommandLineInterface::CommandLineInterface()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::CommandLineInterface::~CommandLineInterface()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::cpp::CppGenerator::CppGenerator()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::cpp::CppGenerator::~CppGenerator()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::java::JavaGenerator::JavaGenerator()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::java::JavaGenerator::~JavaGenerator()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::csharp::Generator::Generator()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::csharp::Generator::~Generator()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::python::Generator::Generator()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::python::Generator::~Generator()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "vtable for google::protobuf::compiler::CodeGenerator", referenced from:
      google::protobuf::compiler::CodeGenerator::CodeGenerator() in main.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "vtable for google::protobuf::compiler::js::Generator", referenced from:
      google::protobuf::compiler::js::Generator::Generator() in main.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "vtable for google::protobuf::compiler::php::Generator", referenced from:
      google::protobuf::compiler::php::Generator::Generator() in main.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "vtable for google::protobuf::compiler::ruby::Generator", referenced from:
      google::protobuf::compiler::ruby::Generator::Generator() in main.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [protoc] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

I have tried to solve it without any progress. Any help is appreciated!


EDITED: for 64bit version also errors. I also follow the google's guide (https://developers.google.com/cardboard/develop/ios/protobuf)

...
  CXXLD    protoc
ld: warning: ignoring file /Users/tom/RefCode/protobuf/src/.libs/libprotobuf.a, building for iOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
ld: warning: ignoring file ./.libs/libprotobuf.a, building for iOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
ld: warning: ignoring file ./.libs/libprotoc.a, building for iOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
Undefined symbols for architecture arm64:
  "google::protobuf::compiler::objectivec::ObjectiveCGenerator::ObjectiveCGenerator()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::objectivec::ObjectiveCGenerator::~ObjectiveCGenerator()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::CodeGenerator::~CodeGenerator()", referenced from:
      google::protobuf::compiler::js::Generator::~Generator() in main.o
      google::protobuf::compiler::ruby::Generator::~Generator() in main.o
      google::protobuf::compiler::php::Generator::~Generator() in main.o
  "google::protobuf::compiler::CommandLineInterface::AllowPlugins(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::CommandLineInterface::RegisterGenerator(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, google::protobuf::compiler::CodeGenerator*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::CommandLineInterface::Run(int, char const* const*)", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::CommandLineInterface::CommandLineInterface()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::CommandLineInterface::~CommandLineInterface()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::cpp::CppGenerator::CppGenerator()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::cpp::CppGenerator::~CppGenerator()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::java::JavaGenerator::JavaGenerator()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::java::JavaGenerator::~JavaGenerator()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::csharp::Generator::Generator()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::csharp::Generator::~Generator()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::python::Generator::Generator()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "google::protobuf::compiler::python::Generator::~Generator()", referenced from:
      google::protobuf::compiler::ProtobufMain(int, char**) in main.o
  "vtable for google::protobuf::compiler::CodeGenerator", referenced from:
      google::protobuf::compiler::CodeGenerator::CodeGenerator() in main.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "vtable for google::protobuf::compiler::js::Generator", referenced from:
      google::protobuf::compiler::js::Generator::Generator() in main.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "vtable for google::protobuf::compiler::php::Generator", referenced from:
      google::protobuf::compiler::php::Generator::Generator() in main.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "vtable for google::protobuf::compiler::ruby::Generator", referenced from:
      google::protobuf::compiler::ruby::Generator::Generator() in main.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [protoc] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
ch271828n
  • 15,854
  • 5
  • 53
  • 88
  • What destination are you building on? Armv7 is for 32-bit device which is too old to use. Is your protobuf imported by source code or by ready made library? If it is ready made, is it support armv7? – Turtleeeeee Sep 26 '21 at 13:36
  • Basically, it's rare for current libraries to support armv7, arm64 is the mostly supported architecture. – Turtleeeeee Sep 26 '21 at 13:39
  • @Turtleeeeee basically i follow https://developers.google.com/cardboard/develop/ios/protobuf . the 64-bit counterpart fails similarly. – ch271828n Sep 26 '21 at 13:41
  • Let me try it out. – Turtleeeeee Sep 26 '21 at 13:50
  • @Turtleeeeee or, can I disable protoc? See this question: https://stackoverflow.com/questions/69335656/how-to-skip-building-protoc-when-compiling-protobuf-from-source-code Thanks! – ch271828n Sep 26 '21 at 14:01
  • @Turtleeeeee by the way I have added the errors for 64bit. – ch271828n Sep 26 '21 at 14:03
  • @Turtleeeeee I have found the solution (see my answer). Thank you for your replies as well! – ch271828n Sep 26 '21 at 14:09
  • 1
    Alright I see it right now. I am downloading the components. The results won't go out so fast. You said skip protoc. I don't think this could be potentially worked. Because there must be some underlying dependency on that, otherwise it won't be showed on an official setup tutorial. – Turtleeeeee Sep 26 '21 at 14:13

1 Answers1

5

Oh I find the answer!

Look at https://github.com/openssl/openssl/issues/10709#issuecomment-589430851 and https://github.com/bitcoin/bitcoin/issues/20825#issuecomment-753444519 , the solution is VERY simple:

brew uninstall binutils

Very interesting error message and the solution...

ch271828n
  • 15,854
  • 5
  • 53
  • 88