Mac OS找不到/usr/include文件夹的解决办法

问题引出:

安装php插件:

phpize提示:

grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory

make后报错:

 fatal error: 'php.h' file not found

究其原因:

/usr/include文件夹不存在,而且由于MAC OS SIP(System Integrity Protection)机制,没有权限在/usr/下创建文件/软链接。此问题也会导致其他开发的错误。

 

Mojave 10.14最新解决方案:

终端执行:

xcode-select --install
#完成后执行
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

结果:此时/usr/include应该就出现了。

 

10.15中苹果为了同时运行不同版本的SDK和Xcode,完全移除了/usr/include

Catalina 10.15解决方案(需要关闭SIP):

#command+R 进入恢复模式后关闭SIP。修改完成后建议启用。
csrutil disable



#已安装可以无视
xcode-select --install

#根目录挂载为可读写
sudo mount -uw /

#建立软链
sudo ln -s "$(xcrun --show-sdk-path)/usr/include" /usr/include


 

/usr/include missing on macOS Catalina (with Xcode 11)

Manually Compiling php插件

 

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值