我刚刚升级到OS X Mountain Lion(已经后悔了)。
在安装jsongem的本机扩展时出现问题。
10.8之前,我安装了命令行工具。带有Ruby 1.9.2的RVM。
升级到10.8并做了以下事情:
- sudo chown-R
whoami
/usr/local - brew更新
- brew tap自制软件/傻瓜
- brew安装apple-gcc42
- 已安装XCode 4.4
- 已安装XCode 4.4的命令行工具
- 导出bash_profile中的CC=/usr/local/bin/gcc-4.2
- sudo ln-s/usr/local/bin/gcc-4.2/usr/bin/gcc-4.2
- 编辑:sudo xcode select-switch/Applications/xcode.app/Contents/Developer
在安装json-gem时,我仍然会得到以下输出:
➽ gem install json -v '1.7.4'
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
/Users/vincent/.rvm/rubies/ruby-1.9.2-p320/bin/ruby extconf.rb
creating Makefile
make
/usr/bin/gcc-4.2 -I. -I/Users/vincent/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/x86_64-darwin11.3.0 -I/Users/vincent/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/ruby/backward -I/Users/vincent/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1 -I. -DJSON_GENERATOR -I/Users/vincent/.rvm/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long -fno-common -pipe -O3 -Wall -O0 -ggdb -o generator.o -c generator.c
gcc-4.2: error trying to exec '/usr/bin/i686-apple-darwin11-gcc-4.2.1': execvp: No such file or directory
make: *** [generator.o] Error 255
Gem files will remain installed in /Users/vincent/.rvm/gems/ruby-1.9.2-p320@hshmrk/gems/json-1.7.4 for inspection.
Results logged to /Users/vincent/.rvm/gems/ruby-1.9.2-p320@hshmrk/gems/json-1.7.4/ext/json/ext/generator/gem_make.out
这里有人帮忙吗?如何调试我的构建环境?在这方面,我不是专家,但我认为json-gem安装程序忽略了我的环境,因为它使用的是我的系统上不存在的GCC版本,而brew安装程序也没有创建它。
➽ gcc-4.2
i686-apple-darwin11-gcc-4.2.1: no input files
➽ which gcc-4.2
/usr/local/bin/gcc-4.2
➽ ls /usr/bin/i686-apple-darwin11-gcc-4.2.1
ls: /usr/bin/i686-apple-darwin11-gcc-4.2.1: No such file or directory
我还尝试了符号链接➽ sudo link /usr/local/bin/gcc-4.2 /usr/bin/i686-apple-darwin11-gcc-4.2.1
。但这导致vfork超时错误。
编辑:
➽ brew doctor
gcc-4.2: error trying to exec '/usr/bin/i686-apple-darwin11-gcc-4.2.1': execvp: No such file or directory
Warning: X11 is not installed.
You don't have X11 installed as part of your OS X installation.
This is not required for all formulae, but is expected by some.
You can download the latest version of XQuartz from:
https://xquartz.macosforge.org
第2版:
确实运行了xcode select xcode
第3版:
sudo xcode-select -switch /usr/bin
sudo ln -sf /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2
这个解决了它!基本上,您告诉OSX使用/usr/bin文件夹进行编译,然后将llvm-gcc-4.2编译器链接到旧编译器所在的位置。有效!砰!
来源:http://jtimberman.housepub.org/blog/2012/02/26/xcode-command-line-tools/
我觉得你所需要做的就是:
sudo ln -sf /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2
我尝试使用xcode选择xcode和命令行工具。他们都工作。我还卸载了brew apple-gcc42,它仍然有效。也不需要导出CC。
所以基本上只是链接。希望这能解决人们的一些问题。
是否运行:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
要让您的系统使用Xcode提供的命令行工具?
这个SO回答中有更多内容。
sudo xcode-select -switch /usr/bin
sudo ln -sf /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2
更简单的方法。。我刚刚通过编辑rbconfig.rb文件~/.rvm/rubies/ruby-1.9.3-p327/lib/rube/1.9.1/x86_64-darwin12.2.0 修复了根问题
由于某种原因,该文件被设置为对CC使用gcc-4.2,而不仅仅是计划gcc(它是llvm-gcc-4.2)。