修复ubuntu 18.10编译grpc各种错误

date_range 2019-04-01 13:21:19 access_time One-minute read

1)error: unrecognized command line option ‘-Wno-invalid-source-encoding’ [-Werror]

解决方法:安装老版本的gcc和g++

 sudo apt-get install gcc-5 g++-5

修改系统环境变量配置

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 500 --slave 
/usr/bin/g++ g++ /usr/bin/g++-5
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave 
/usr/bin/g++ g++ /usr/bin/g++-8

选择想要的gcc版本

sudo update-alternatives --config gcc

2)src/core/lib/iomgr/tcp_posix.cc:625:42: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]

解决方法:修改gcc编译参数,增加-fno-strict-aliasing

vi ./Makefile

搜索CXXFLAGS += -std=c++11,大概在351行(grpc v1.19.1版本)修改为

CXXFLAGS += -std=c++11 -fno-strict-aliasing

即可解决

comments

comments powered by Disqus