[英]OS X Mountain Lion: gcc-4.2 No such file or directory
Tried to install a gem on Mountain Lion and make couldn't find gcc-4.2:试图在 Mountain Lion 上安装一个 gem 并且 make 找不到 gcc-4.2:
kamil$ gem install posix-spawn -v '0.3.6'
Building native extensions. This could take a while...
ERROR: Error installing posix-spawn:
ERROR: Failed to build gem native extension.
/Users/kamil/.rbenv/versions/1.9.3-p0/bin/ruby extconf.rb
creating Makefile
make
compiling posix-spawn.c
make: gcc-4.2: No such file or directory
make: *** [posix-spawn.o] Error 1
If you have Xcode installed, gcc should be available.如果您安装了 Xcode,则应该可以使用 gcc。 Check where it is with:
检查它在哪里:
kamil$ which gcc
/usr/bin/gcc
Then make a user-land symbolic link from gcc-4.2 to plain gcc:然后创建一个从 gcc-4.2 到普通 gcc 的用户级符号链接:
kamil$ sudo ln -s ~/bin/gcc /usr/bin/gcc-4.2
(Ensure the user-land bind folder is in your path via export PATH=...:$HOME/bin
in your .bash_profile
or .zshrc
.) (通过
.bash_profile
或.zshrc
export PATH=...:$HOME/bin
确保用户土地绑定文件夹在您的路径中。)
Gem installed fine afterwards.之后 Gem 安装得很好。
As @Artur Bodera mentioned modern OSX will refuse to let you create the symlink in the systems /bin folder.正如@Artur Bodera 提到的,现代 OSX 将拒绝让您在系统 /bin 文件夹中创建符号链接。
To avoid this simply create the symlink to your users bin folder为避免这种情况,只需创建指向用户 bin 文件夹的符号链接
ln -s ~/bin/gcc /usr/bin/gcc-4.2
Don't forget to add the bin folder to your .zshrc or .bash_profile - eg不要忘记将 bin 文件夹添加到您的 .zshrc 或 .bash_profile - 例如
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$HOME/bin
I had a similar issue while installing a python pip package (building a wheel failed).我在安装 python pip 包时遇到了类似的问题(构建轮子失败)。 I got the similar message:
我收到了类似的消息:
unable to execute '/usr/bin/gcc-4.2': No such file or directory
error: command '/usr/bin/gcc-4.2' failed with exit status 1
Linking /usr/bin/gcc-4.2
to /usr/bin/gcc
was not possible due to Apples System Integrity Protection (SIP), and linking it to /usr/local/bin/gcc-4.2
was not picked up by the wheel building process;由于 Apples 系统完整性保护 (SIP),无法将
/usr/bin/gcc-4.2
链接到/usr/bin/gcc
,并且无法将其链接到/usr/local/bin/gcc-4.2
建造过程; it was still trying to use /usr/bin/gcc-4.2
.它仍在尝试使用
/usr/bin/gcc-4.2
。
I was finally able to solve this by setting the CC
variable in the terminal:我终于能够通过在终端中设置
CC
变量来解决这个问题:
CC=/usr/bin/gcc
# Install your packages
pip install -r requirements.txt
PS : note that disabling SIP doesn't work, even with SIP disabled I wasn't able to create the /usr/bin/gcc-4.2
link. PS:请注意,禁用 SIP 不起作用,即使禁用了 SIP 我也无法创建
/usr/bin/gcc-4.2
链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.