我是靠谱客的博主 友好钢笔,这篇文章主要介绍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插件

 

最后

以上就是友好钢笔最近收集整理的关于Mac OS找不到/usr/include文件夹的解决办法的全部内容,更多相关Mac内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(149)

评论列表共有 0 条评论

立即
投稿
返回
顶部