gRPC c++ helloworld program compilation error

932 views
Skip to first unread message

Bugsfunny

unread,
May 16, 2017, 7:06:00 AM5/16/17
to grpc.io
Hi,

I installed grpc 1.3.0 and protobuf 3.2.0  in OSX El Captain 10.11.6.
I had some problems installing which gave errors saying "ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'"
Then i installed c-ares from homebrew "brew install c-ares".
Installed grpc successfully after that.


Then I tried running "make" in the helloworld (cpp examples directory), but got the below errors:

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


please help me with the above errors..

Thanks










Nicolas Noble

unread,
May 16, 2017, 7:46:09 PM5/16/17
to grpc.io
For us to be able to help a bit more with your issue, we'd need to understand how you built grpc and protobuf before. All signs are pointing at the fact you've built protobuf for 32 bits whereas the rest is building for 64 bits, but without more details it's hard to tell.

Bugsfunny

unread,
May 16, 2017, 10:46:53 PM5/16/17
to grpc.io
I built it from git using the following commands :

 $ git clone -b $(curl -L http://grpc.io/release) https://github.com/grpc/grpc
 $ cd grpc
 $ git submodule update --init
 $ make
 $ [sudo] make install

When running "make" from the above list of commands, I got the warning "ld: warning: directory not found for option '-L/<path>/grpc/libs/opt/c-ares'" and was not able to install. Then I installed c-ares using "brew install c-ares". After which "make" worked fine. 
And then since protobuf was not automatically installed i executed the following commands :

$ cd grpc/third_party/protobuf
$ sudo make install   # 'make' should have been run by core grpc

Thanks.

Bugsfunny

unread,
May 19, 2017, 12:19:20 AM5/19/17
to grpc.io
Please help me with this.....

Bugsfunny

unread,
May 21, 2017, 4:36:15 AM5/21/17
to grpc.io
Please help me ....

Noah Eisen

unread,
May 21, 2017, 8:30:33 PM5/21/17
to Bugsfunny, grpc.io
Not sure exactly what would cause this, but I would suggest doing a clean re-install of grpc and protobuf. Check out the steps detailed in the comment thread of https://github.com/grpc/grpc/issues/10909. There are a few more steps needed to install protobuf than the ones you mention.

Also, would suggest uninstalling the brew version of c ares and installing the one in the third_party directory, just to ensure that the installed version matches the one the code. 

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscribe@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/cdf05f49-8262-484f-8961-7713a8a6887c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages