安装swoole扩展报错 #define UNEXPECTED(condition) __builtin_expect(!!(condition), 0) lmake: *** [php_swoole_cxx.lo] Error 1

在docker 的PHP容器内安装swoole扩展报错:

xxxxxxxxxx
#define
UNEXPECTED(condition) __builtin_expect(!!(condition), 0)

make: *** [php_swoole_cxx.lo] Error 1

方案:解决gcc版本过低的问题

# 先进入php容器
docker exec -it {php容器ID或名称} bash
yum -y install centos-release-scl
yum -y install devtoolset-7
scl enable devtoolset-7 bash

# 下载、安装
wget https://github.com/swoole/swoole-src/archive/v4.2.1.tar.gz &&
	tar -zxvf v4.2.1.tar.gz &&
	cd swoole-src-4.2.1 &&
	phpize &&
	./configure &&
	make && make install &&
	sed -i '$a \n[swoole]
extension=swoole.so' /etc/php.ini &&
cd ../ && rm -rf v4.2.1.tar.gz swoole-src-4.2.1
# 退出PHP容器
[root@510d01c199f5 /]# exit
exit

# 重启PHP容器
[root@localhost xxx]# docker restart  {php容器ID或名称}
 
另外, 如果要升级swoole扩展也是安装这个步骤来重新装一次!
原文地址:https://www.cnblogs.com/pyspang/p/13567642.html