简体   繁体   English

安装gRPC:ld:警告:找不到选项&#39;-L /的目录 <path> / GRPC /库/选择/ C-顷

[英]Installing gRPC : ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'

OS -> OSX El Captain Version 10.11.6

Tried to install gRPC using the below commands: 尝试使用以下命令安装gRPC:

  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 : 卸载protobuf并再次运行make之后,我得到以下警告:

    [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). 如果我通过执行'sudo make install'进行安装,则不会安装protobuf并且grpc_cpp_plugin无法正常工作(给出以下错误)。

    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 . 对于c-ares问题,我使用自制brew install c-ares安装了它。 Then installed grpc grpc-1.3.0.tar.gz and protobuf libprotoc 3.2.0 without errors. 然后安装grpc grpc-1.3.0.tar.gz和protobuf libprotoc 3.2.0没有错误。 But when i run make in the helloworld example, i'm getting the below error : 但是当我在helloworld示例中运行make时,出现以下错误:

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 谢谢

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. 它可能与已安装的ProtoBuf版本错误或损坏有关,因为如果已安装protobuf且版本高于3.0,则gRPC构建系统使用系统的protobuf会从subrepo中读取thrird-party-protobuf。 Try to remove or fix protobuf in your system. 尝试删除或修复系统中的protobuf。

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. 更新:对于新问题,请尝试为每个grpc和protobuf库运行“ readelf -s lib ???。so”,并尝试在库中找到此符号。 If in some library is specified "UND", than it is wrong library. 如果在某些库中指定了“ UND”,那么它是错误的库。 Second things that you should do, run "file lib???.so" for each grpc and protobuf library for check binary type: x86_64 or not. 您应该做的第二件事,对每个grpc和protobuf库运行“文件lib ???。so”以检查二进制类型:x86_64或不行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM