1、下载 vcpkg 并安装;
cd /opt
git clone https://github.com/microsoft/vcpkg
cd vcpkg
./bootstrap-vcpkg.sh
2、安装gcc等编译工具
dnf install make gcc gcc-c++
3、开始安装 grpc
./vcpkg install grpc
4、安装过程中可能遇到的问题
4.1 可能无法下载 github 上的资源,需要设置 proxy
export https_proxy=http://ip:port
export http_proxy=http://ip:port
4.2 grpc 编译不成功,由于 gcc 版本太低所致,需要 gcc 9 以上版本
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
sed -i 's/$releasever/8/g' /etc/yum.repos.d/CentOS-Base.repo
yum install gcc-toolset-9-gcc gcc-toolset-9-gcc-c++
gcc -v # 显示 gcc 7
source /opt/rh/gcc-toolset-9/enable
gcc -v # 显示 gcc 9