综合分析结果:
centos7.7 默认的gcc版本是 4.8 的;
然而 php的grpc扩展安装,需要 gcc 4.9 + 以上的版本;
所以需要先升级 gcc,然后再进行扩展的安装
# 注意如果使用的宝塔环境的时候,在对gcc进行编译安装的时候,需要制定 php-config
phpize
./configure --with-php-config=/www/server/php/73/bin/php-config
make
make install
使用源码安装,报错信息如下:
/www/software/grpc-1.34.0/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc: In member function ‘virtual std::string grpc_core::{anonymous}::GrpcLb::TokenAndClientStatsAttribute::ToString() const’:
/www/software/grpc-1.34.0/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc:278:49: error: no matching function for call to ‘StrFormat(const char [30], const string&, grpc_core::GrpcLbClientStats*)’
client_stats_.get());
^
/www/software/grpc-1.34.0/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc:278:49: note: candidate is:
In file included from /www/software/grpc-1.34.0/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc:69:0:
/www/software/grpc-1.34.0/third_party/abseil-cpp/absl/strings/str_format.h:338:34: note: template<class ... Args> std::string absl::lts_2020_09_23::StrFormat(absl::lts_2020_09_23::FormatSpec<Args ...>&, const Args& ...)
ABSL_MUST_USE_RESULT std::string StrFormat(const FormatSpec<Args...>& format,
^
/www/software/grpc-1.34.0/third_party/abseil-cpp/absl/strings/str_format.h:338:34: note: template argument deduction/substitution failed:
/www/software/grpc-1.34.0/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc:278:49: note: mismatched types ‘absl::lts_2020_09_23::FormatSpec<Args ...>’ and ‘const char [30]’
client_stats_.get());
^
/www/software/grpc-1.34.0/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc: In member function ‘std::string grpc_core::{anonymous}::GrpcLb::Serverlist::AsText() const’:
/www/software/grpc-1.34.0/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc:525:72: error: no matching function for call to ‘StrFormat(const char [20], size_t&, std::string&, const char [50])’
ipport, server.load_balance_token));
^
/www/software/grpc-1.34.0/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc:525:72: note: candidate is:
In file included from /www/software/grpc-1.34.0/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc:69:0:
/www/software/grpc-1.34.0/third_party/abseil-cpp/absl/strings/str_format.h:338:34: note: template<class ... Args> std::string absl::lts_2020_09_23::StrFormat(absl::lts_2020_09_23::FormatSpec<Args ...>&, const Args& ...)
ABSL_MUST_USE_RESULT std::string StrFormat(const FormatSpec<Args...>& format,
^
/www/software/grpc-1.34.0/third_party/abseil-cpp/absl/strings/str_format.h:338:34: note: template argument deduction/substitution failed:
/www/software/grpc-1.34.0/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc:525:72: note: mismatched types ‘absl::lts_2020_09_23::FormatSpec<Args ...>’ and ‘const char [20]’
ipport, server.load_balance_token));
^
make: *** [src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.lo] Error 1
原因分析:
需要安装 you need gcc version 4.9+
升级gcc
1、安装centos-release-scl
sudo yum install centos-release-scl
2、安装devtoolset,注意,如果想安装7.*版本的,就改成devtoolset-7-gcc*,以此类推
sudo yum install devtoolset-8-gcc*
3、激活对应的devtoolset,所以你可以一次安装多个版本的devtoolset,需要的时候用下面这条命令切换到对应的版本
scl enable devtoolset-8 bash
大功告成,查看一下gcc版本
gcc -v
每个版本的目录下面都有个 enable 文件,如果需要启用某个版本,只需要执行
source /opt/rh/devtoolset-8/enable