0
OS -> OSX El Captain Version 10.11.6

Tried to install gRPC using the below commands:

  1. git clone-b $(curl -L http://grpc.io/release) https://github.com/grpc/grpc
  2. cd grpc
  3. git submodule update --init
  4. make

I got the below error:

    [HOSTCXX] Compiling src/compiler/cpp_plugin.cc
    [HOSTLD]  Linking /<path>/grpc/bins/opt/grpc_cpp_plugin
    ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
    Undefined symbols for architecture x86_64: 
    "google::protobuf::io::StringOutputStream::StringOutputStream(std::__1::basic_string<char, std::__1::char_traits<char>, 
    std::__1::allocator<char> >*)", referenced from:
    ProtoBufFile::CreatePrinter(std::__1::basic_string<char, 
    std::__1::char_traits<char>, std::__1::allocator<char> >*) const in cpp_plugin.o

    "google::protobuf::io::Printer::Print(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<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&, char const*)", referenced from:
  ProtoBufPrinter::Print(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<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&, char const*) in cpp_plugin.o

     "google::protobuf::FileDescriptor::GetSourceLocation(std::__1::vector<int, std::__1::allocator<int> > const&, google::protobuf::SourceLocation*) const", referenced from:
  void grpc_generator::GetComment<google::protobuf::FileDescriptor>(google::protobuf::FileDescriptor const*, grpc_generator::CommentType, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >*) in cpp_plugin.o
    "google::protobuf::compiler::CodeGenerator::GenerateAll(std::__1::vector<google::protobuf::FileDescriptor const*, std::__1::allocator<google::protobuf::FileDescriptor const*> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, google::protobuf::compiler::GeneratorContext*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) const", referenced from:
  vtable for CppGrpcGenerator in cpp_plugin.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [/<path>/grpc/bins/opt/grpc_cpp_plugin] Error 1

This is what I have in

/<path>/grpc/libs/opt/ directory :
 - libares.a    
 - libgpr.a
 - libgrpc_cronet.a     
 - libgrpc_unsecure.a
 - libboringssl.a
 - libgrpc.a            
 - libgrpc_plugin_support.a 
 - pkgconfig

[EDIT]

After uninstalling protobuf and running make again I get the below warnings :

    [LD]      Linking /<path>/grpc/libs/opt/libgpr.dylib
    ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
    [LD]      Linking /<path>/grpc/libs/opt/libgrpc.dylib
    ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
    [LD]      Linking /<path>/grpc/libs/opt/libgrpc_cronet.dylib
    ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
    [LD]      Linking /<path>/grpc/libs/opt/libgrpc_unsecure.dylib
    ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
    [LD]      Linking /<path>/grpc/libs/opt/libgrpc++.dylib
    ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
    [LD]      Linking /<path>/grpc/libs/opt/libgrpc++_cronet.dylib
    ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
    [LD]      Linking /<path>/grpc/libs/opt/libgrpc++_error_details.dylib
    ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
    [LD]      Linking /<path>/grpc/libs/opt/libgrpc++_reflection.dylib
    ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'
    [LD]      Linking /<path>/grpc/libs/opt/libgrpc++_unsecure.dylib
    ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'

If I proceed with the installation by executing 'sudo make install', protobuf doesn't get installed and grpc_cpp_plugin doesn't work (gives the below error).

    grpc_cpp_plugin: program not found or is not executable
    --grpc_out: protoc-gen-grpc: Plugin failed with status code 1.

[EDIT]

For the c-ares problem, i installed it using homebrew brew install c-ares. Then installed grpc grpc-1.3.0.tar.gz and protobuf libprotoc 3.2.0 without errors. But when i run make in the helloworld example, i'm getting the below error :

protoc -I ../../protos --cpp_out=. ../../protos/helloworld.proto
g++ -std=c++11 -I/usr/local/include -pthread  -c -o helloworld.pb.o helloworld.pb.cc
protoc -I ../../protos --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ../../protos/helloworld.proto
g++ -std=c++11 -I/usr/local/include -pthread  -c -o helloworld.grpc.pb.o helloworld.grpc.pb.cc
g++ -std=c++11 -I/usr/local/include -pthread  -c -o greeter_client.o greeter_client.cc
g++ helloworld.pb.o helloworld.grpc.pb.o greeter_client.o -L/usr/local/lib `pkg-config --libs grpc++ grpc` -lgrpc++_reflection -lprotobuf -lpthread -ldl -o greeter_client
Undefined symbols for architecture x86_64:
  "grpc::CreateChannel(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::shared_ptr<grpc::ChannelCredentials> const&)", referenced from:
      _main in greeter_client.o
  "google::protobuf::MessageFactory::InternalRegisterGeneratedFile(char const*, void (*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&))", referenced from:
      helloworld::protobuf_helloworld_2eproto::AddDescriptorsImpl()       in helloworld.pb.o
  "google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*)", referenced from:
      google::protobuf::internal::WireFormatLite::WriteStringToArray(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*) in helloworld.pb.o
  "google::protobuf::internal::ArenaStringPtr::AssignWithDefault(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*, google::protobuf::internal::ArenaStringPtr)", referenced from:
      helloworld::HelloRequest::HelloRequest(helloworld::HelloRequest const&) in helloworld.pb.o
      helloworld::HelloRequest::HelloRequest(helloworld::HelloRequest const&) in helloworld.pb.o
      helloworld::HelloRequest::MergeFrom(helloworld::HelloRequest const&) in helloworld.pb.o
      helloworld::HelloReply::HelloReply(helloworld::HelloReply const&) in helloworld.pb.o
      helloworld::HelloReply::HelloReply(helloworld::HelloReply const&) in helloworld.pb.o
      helloworld::HelloReply::MergeFrom(helloworld::HelloReply const&) in helloworld.pb.o
  "google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::io::CodedOutputStream*)", referenced from:
      helloworld::HelloRequest::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const  in helloworld.pb.o
      helloworld::HelloReply::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const  in helloworld.pb.o
  "google::protobuf::internal::WireFormatLite::ReadBytes(google::protobuf::io::CodedInputStream*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)", referenced from:
      google::protobuf::internal::WireFormatLite::ReadString(google::protobuf::io::CodedInputStream*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) in helloworld.pb.o
  "google::protobuf::internal::AssignDescriptors(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::internal::MigrationSchema const*, google::protobuf::Message const* const*, unsigned int const*, google::protobuf::MessageFactory*, google::protobuf::Metadata*, google::protobuf::EnumDescriptor const**, google::protobuf::ServiceDescriptor const**)", referenced from:
      helloworld::protobuf_helloworld_2eproto::(anonymous namespace)::protobuf_AssignDescriptors() in helloworld.pb.o
  "google::protobuf::internal::fixed_address_empty_string[abi:cxx11]", referenced from:
      google::protobuf::internal::GetEmptyStringAlreadyInited[abi:cxx11]() in helloworld.pb.o
      google::protobuf::internal::GetEmptyStringAlreadyInited[abi:cxx11]() in greeter_client.o
  "google::protobuf::Message::GetTypeName[abi:cxx11]() const", referenced from:
      vtable for helloworld::HelloReply in helloworld.pb.o
      vtable for helloworld::HelloRequest in helloworld.pb.o
  "google::protobuf::Message::InitializationErrorString[abi:cxx11]() const", referenced from:
      vtable for helloworld::HelloReply in helloworld.pb.o
      vtable for helloworld::HelloRequest in helloworld.pb.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [greeter_client] Error 1

Thanks

Akshay
  • 1
  • 4

1 Answers1

0

It could be related with wrong or corrupted version of installed ProtoBuf, because if protobuf is installed and has version more than 3.0, than gRPC building system uses system's protobuf, instread thrird-party-protobuf from subrepo. Try to remove or fix protobuf in your system.

UPDATE: For new issues try to run "readelf -s lib???.so" for each grpc and protobuf library, and try to find this symbols in libraries. If in some library is specified "UND", than it is wrong library. Second things that you should do, run "file lib???.so" for each grpc and protobuf library for check binary type: x86_64 or not.

knst
  • 523
  • 2
  • 16