检查C编译器是否正常工作...没有

Ava*_*Ava 13 ruby compiler-construction xcode gcc rvm

我最近卸载了Xcode 4.2并重新安装了Xcode 4.3.1.Command Line Tools也安装了.错误说"C编译器不起作用".在搜索此错误时,它表示在未安装Xcode时会发生这种情况.我错过了什么?

rvm install 1.9.3 --with-gcc=clang
Installing Ruby from source to: /Users/ava/.rvm/rubies/ruby-1.9.3-preview1, this may take a while depending on your cpu(s)...

ruby-1.9.3-preview1 - #fetching 
ruby-1.9.3-preview1 - #extracting ruby-1.9.3-preview1 to /Users/ava/.rvm/src/ruby-1.9.3-preview1
ruby-1.9.3-preview1 - #extracted to /Users/ava/.rvm/src/ruby-1.9.3-preview1
Fetching yaml-0.1.4.tar.gz to /Users/ava/.rvm/archives
Extracting yaml-0.1.4.tar.gz to /Users/ava/.rvm/src
Configuring yaml in /Users/ava/.rvm/src/yaml-0.1.4.
ERROR: Error running ' ./configure --prefix="/Users/ava/.rvm/usr"  --with-gcc=clang           --build=x86_64-apple-darwin11.3.0           --host=x86_64-apple-darwin11.3.0           --build=x86_64-apple-darwin11.3.0           --host=x86_64-apple-darwin11.3.0 ', please read /Users/ava/.rvm/log/ruby-1.9.3-preview1/yaml/configure.log
Compiling yaml in /Users/ava/.rvm/src/yaml-0.1.4.
ERROR: Error running '/usr/bin/make ', please read /Users/ava/.rvm/log/ruby-1.9.3-preview1/yaml/make.log
Installing yaml to /Users/ava/.rvm/usr
ERROR: Error running '/usr/bin/make install', please read /Users/ava/.rvm/log/ruby-1.9.3-preview1/yaml/make.install.log
ruby-1.9.3-preview1 - #configuring 
ERROR: Error running ' ./configure --prefix=/Users/ava/.rvm/rubies/ruby-1.9.3-preview1 --enable-shared --disable-install-doc  --with-gcc=clang           --build=x86_64-apple-darwin11.3.0           --host=x86_64-apple-darwin11.3.0           --build=x86_64-apple-darwin11.3.0           --host=x86_64-apple-darwin11.3.0 --with-libyaml-dir=/Users/ava/.rvm/usr ', please read /Users/ava/.rvm/log/ruby-1.9.3-preview1/configure.log
ERROR: There has been an error while running configure. Halting the installation.


?  yaml git:(master) ? vi configure.log 

[2012-03-18 21:03:00]  ./configure --prefix="/Users/ava/.rvm/usr"  --with-gcc=clang           --build=x86_64-apple-darwin11.3.0           --host=x86_64-apple-darwin11.3.0           --build=x86_64-apple-darwin11.3.0           --host=x86_64-apple-darwin11.3.0
configure: WARNING: unrecognized options: --with-gcc
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... config/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking for x86_64-apple-darwin11.3.0-gcc... no
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/Users/ava/.rvm/src/yaml-0.1.4':
configure: error: C compiler cannot create executables
See `config.log' for more details


?  ~ git:(master) ? gcc -v   
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.9~22/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.9~22/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)


?  ~ git:(master) ? which gcc
/usr/bin/gcc
Run Code Online (Sandbox Code Playgroud)

Kur*_*vis 23

在终端:

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
Run Code Online (Sandbox Code Playgroud)

此外,在Xcode中,确保已安装命令行工具.选择Xcode> Preferences,单击Downloads,如有必要,单击"Command Line Tools"旁边的Install按钮.

  • 不,它仍然失败 (6认同)

mpa*_*pis 7

  1. 你使用旧的RVM,不知道最新的ruby pathclevel,更新 rvm get head

  2. Ruby还没有为LLVM做好充分准备,使用osx-gcc-installer和你的编译是最好的机会 --with-gcc=gcc-4.2

  • 是的,但只有1.9.3-p125,它仍有问题,我听说1.9.3头更好 - 但仍然不是一切 (2认同)

小智 5

我通过运行修复它:

rvm install <ruby-version> --with-gcc=clang
Run Code Online (Sandbox Code Playgroud)

将<ruby-version>替换为您要使用的版本