0

Recently I have started working on Grpc. On Grpc C++ compilation I get below error, not sure what is caused the issue.

I am not from C++ background, any help will be much useful for me.

[HOSTLD] Linking /home/test/grpc/bins/opt/grpc_ruby_plugin [PROTOC] Generating protobuf CC file from src/proto/grpc/channelz/channelz.proto [GRPC] Generating gRPC's protobuf service CC file from src/proto/grpc/channelz/channelz.proto

terminate called after throwing an instance of 'std::system_error'

what(): Unknown error -1

--grpc_out: protoc-gen-grpc: Plugin killed by signal 6.

make: *** [/home/test/grpc/gens/src/proto/grpc/channelz/channelz.grpc.pb.cc] Error 1

Before the I was trying cross compilation and that was resulted in "grpc segmentation fault" on helloworld communication. To clear that I have followed below step.

I nuked my /usr/local/lib/ and cleared out all proto and grpc libs

rm -f /usr/local/lib/libproto* /usr/local/lib/libgrpc*

Cleaned everything

git submodule foreach git clean -xfd

git clean -xfd

Then re-installed everything but still, I get the above error. Can someone please help me on this issue?

Note: I removed the complete grpc folder, recloned it. Installed protobuf and the protobuf installation is successful but when I give "make" command in gRPC I get above error.

When I googled it, this looks to be some generic error from c++ side.

Below are steps which I have followed.:

• git clone -b $(curl -L http://grpc.io/release) https://github.com/grpc/grpc

• cd grpc

• git submodule update --init

• cd third_party/protobuf

• ./Autogen.sh

• ./configure

• make && make install (Protobuf installation is successful)

• go to grpc folder and give make.

This is not successful, throws terminate called after throwing an instance of 'std::system_error'

Murali Perumal
  • 309
  • 1
  • 5
  • 13
  • Use a debugger to find the point where the exception is thrown (this means that there is error checking code in the program which intentionally throws when an OS call returns a failure code) – M.M Dec 03 '18 at 02:12
  • It comes from libprotobuf FATAL google/protobuf/generated_message_util.cc:785] CHECK failed: I am sure that all was working properly, to avoid some issue I have removed "rm -f /usr/local/lib/libproto* /usr/local/lib/libgrpc*" after this only, I am facing all these issues. – Murali Perumal Dec 03 '18 at 02:29
  • Looks like pthread library is missing but not sure how to add it. – Murali Perumal Dec 03 '18 at 02:41

1 Answers1

3

I got the solution for this, its due to pthread was not configured properly.

executing below command from protobuf folder solved the issue.

pkg-config --cflags protobuf # print compiler flags

pkg-config --libs protobuf # print linker flags

pkg-config --cflags --libs protobuf # print both

./configure CXXFLAGS="$(pkg-config --cflags protobuf)" LIBS="$(pkg-config --libs protobuf)"

make

[sudo] make install

go to grpc folder and run make command.

Murali Perumal
  • 309
  • 1
  • 5
  • 13
  • Great! I encountered the same problem, your solution worked for me. Many thanks! – Ben Chen Feb 28 '19 at 08:42
  • There is an open issue on github/googlesamples https://github.com/googlesamples/assistant-sdk-cpp/pull/54, maybe they need take your answer as their solution. I wonder how did you find this solution. – Ben Chen Feb 28 '19 at 09:27
  • 1
    In my case what I simply needed to do was adding "-lpthread" to my compilation command – Diego Pino Dec 08 '19 at 19:05