我正在为学校做一个项目,我们必须为c++安装gRPC和protocol buffer依赖项。我一直按照Ubuntu19上的构建说明进行构建,当我从根grpc/运行make时,我得到了下面的错误。
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我的protoc版本
libprotoc 3.0.0我的gcc版本
gcc (Ubuntu 8.3.0-6ubuntu1) 8.3.0发布于 2019-10-18 00:30:17
看起来降级到gcc-7和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
然后我将gcc-7设置为最高优先级
sudo update-alternatives --config gcc
然后我再次尝试make install,没有任何错误。
https://stackoverflow.com/questions/58433500
复制相似问题