PHP 安裝 grpc 擴(kuò)展報(bào)錯(cuò)

綜合分析結(jié)果:
centos7.7 默認(rèn)的gcc版本是 4.8 的;
然而 php的grpc擴(kuò)展安裝,需要 gcc 4.9 + 以上的版本;
所以需要先升級(jí) gcc,然后再進(jìn)行擴(kuò)展的安裝

# 注意如果使用的寶塔環(huán)境的時(shí)候,在對(duì)gcc進(jìn)行編譯安裝的時(shí)候,需要制定 php-config
phpize
./configure --with-php-config=/www/server/php/73/bin/php-config
make 
make install

使用源碼安裝,報(bào)錯(cuò)信息如下:

/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 ‘a(chǎn)bsl::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 ‘a(chǎn)bsl::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+

升級(jí)gcc

1、安裝centos-release-scl

sudo yum install centos-release-scl
2、安裝devtoolset,注意,如果想安裝7.*版本的,就改成devtoolset-7-gcc*,以此類推

sudo yum install devtoolset-8-gcc*
3、激活對(duì)應(yīng)的devtoolset,所以你可以一次安裝多個(gè)版本的devtoolset,需要的時(shí)候用下面這條命令切換到對(duì)應(yīng)的版本

scl enable devtoolset-8 bash
大功告成,查看一下gcc版本

gcc -v

 每個(gè)版本的目錄下面都有個(gè) enable 文件,如果需要啟用某個(gè)版本,只需要執(zhí)行
source /opt/rh/devtoolset-8/enable

參考鏈接

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容