gRPC fails when building from source

30 views
Skip to first unread message

David T.

unread,
Oct 17, 2019, 9:16:09 AM10/17/19
to grpc.io
I'm doing a project for school and we have to install gRPC and protocol buffer dependencies for c++. I have been following the build instructions here https://github.com/grpc/grpc/blob/master/BUILDING.md I am building on Ubuntu 19 and when I run make from the root grpc/ I get the below error.

src/cpp/common/channel_filter.cc: In member function ‘grpc_linked_mdelem* grpc::MetadataBatch::AddMetadata(const string&, const string&)’:
src/cpp/common/channel_filter.cc:33:48: error: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘grpc_linked_mdelem’ {aka ‘struct grpc_linked_mdelem’}; use assignment or value-initialization instead [-Werror=class-memaccess]
   memset(storage, 0, sizeof(grpc_linked_mdelem));
                                                ^
In file included from ./src/core/lib/transport/transport.h:34,
                 from ./src/core/lib/channel/channel_stack.h:48,
                 from src/cpp/common/channel_filter.cc:21:
./src/core/lib/transport/metadata_batch.h:33:16: note: ‘grpc_linked_mdelem’ {aka ‘struct grpc_linked_mdelem’} declared here
 typedef struct grpc_linked_mdelem {
                ^~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make: *** [Makefile:2926: /home/n0auth/Project3/grpc/objs/opt/src/cpp/common/channel_filter.o] Error 1

My protoc version

libprotoc 3.0.0

My gcc version

gcc (Ubuntu 8.3.0-6ubuntu1) 8.3.0

What am I doing wrong?

Thomas Mercier

unread,
Oct 17, 2019, 11:45:59 AM10/17/19
to David T., grpc.io
Nothing, I think. It looks like gRPC just doesn't build with GCC 8 (which has added more checks/warnings that the gRPC build is treating as errors). Someone else filed a bug about this: https://github.com/grpc/grpc/issues/18689

Removing -Werror as Triose suggested, or adding -Wno-error=class-memaccess should let you build 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+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/e825be31-8f3e-4bd9-8256-a4e0dfa31480%40googlegroups.com.

David T.

unread,
Oct 17, 2019, 12:26:16 PM10/17/19
to grpc.io
Hey thanks!
I think I've figured it out.
First I downgraded to gcc-7 as well as g++-7

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 --slave /usr/bin/g++ g++ /usr/bin/g++-7 --slave /usr/bin/gcov gcov /usr/bin/gcov-7

Then I set gcc-7 with highest priority
sudo update-alternatives --config gcc

There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

  Selection    Path            Priority   Status
------------------------------------------------------------
  0            /usr/bin/gcc-9   90        auto mode
  1            /usr/bin/gcc-7   70        manual mode
* 2            /usr/bin/gcc-9   90        manual mode

Press <enter> to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/bin/gcc-7 to provide /usr/bin/gcc (gcc) in manual mode

Then sudo make install at the root directory of grpc/ and I didn't get any errors.

Changed directories to the examples examples/cpp/helloworld and ran make against the helloworld examples.


~/Project3/grpc/examples/cpp/helloworld(9dfbd34f5c ✔) make
protoc -I ../../protos --cpp_out=. ../../protos/helloworld.proto
g++ -std=c++11 `pkg-config --cflags protobuf grpc` -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 `pkg-config --cflags protobuf grpc` -c -o helloworld.grpc.pb.o helloworld.grpc.pb.cc
g++ -std=c++11 `pkg-config --cflags protobuf grpc` -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 protobuf grpc++ grpc` -Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed -ldl -o greeter_client
g++ -std=c++11 `pkg-config --cflags protobuf grpc` -c -o greeter_server.o greeter_server.cc
g++ helloworld.pb.o helloworld.grpc.pb.o greeter_server.o -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc` -Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed -ldl -o greeter_server
g++ -std=c++11 `pkg-config --cflags protobuf grpc` -c -o greeter_async_client.o greeter_async_client.cc
g++ helloworld.pb.o helloworld.grpc.pb.o greeter_async_client.o -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc` -Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed -ldl -o greeter_async_client
g++ -std=c++11 `pkg-config --cflags protobuf grpc` -c -o greeter_async_client2.o greeter_async_client2.cc
g++ helloworld.pb.o helloworld.grpc.pb.o greeter_async_client2.o -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc` -Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed -ldl -o greeter_async_client2
g++ -std=c++11 `pkg-config --cflags protobuf grpc` -c -o greeter_async_server.o greeter_async_server.cc
g++ helloworld.pb.o helloworld.grpc.pb.o greeter_async_server.o -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc` -Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed -ldl -o greeter_async_server


To unsubscribe from this group and stop receiving emails from it, send an email to grp...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages