【问题标题】:checking whether the C compiler works... no检查 C 编译器是否工作...否
【发布时间】:2012-03-19 04:58:58
【问题描述】:

我最近卸载了 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

【问题讨论】:

  • 您可以简单地将CC=clang 作为命令行上的环境变量传递给configure 或任何调用它的东西吗?
  • 你的意思是在终端上是这样的? ➜ ~ git:(master) ✗ CC=clang ➜ ~ git:(master) ✗

标签: ruby xcode gcc compiler-construction rvm


【解决方案1】:

在终端中:

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

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

【讨论】:

  • ➜ ~ git:(master) ✗ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer Password: ➜ ~ git:(master) ✗ 没有任何反应。
  • xcode-select 不打印任何东西,是的,但是在你完成之后构建工作吗?你没有说你是否再试一次。
  • 这篇文章帮助了我:stackoverflow.com/a/13595772/1008519 它创建了一个符号链接,以便编译器能够找到工具链
  • 为我工作。我有一个开发者预览版并安装了另一个版本。
【解决方案2】:
  1. 你使用旧的 RVM,它不知道最新的 ruby​​ pathclevel,更新为rvm get head

  2. Ruby 还没有为 LLVM 做好充分准备,使用 osx-gcc-installer 和 --with-gcc=gcc-4.2

【讨论】:

  • Ruby 1.9.3 可以用clang编译。
  • 是的,但只有 1.9.3-p125,它仍然有问题,我听说 1.9.3-head 更好 - 但仍然不是全部
  • 我设法使用以下命令安装了ruby-1.9.3 p484gcc-4.9rvm install ruby-1.9.3-p484 --with-gcc=gcc-4.9 感谢分享此评论;很有用!
  • +1 表示rvm install ruby-1.9.3-p484 --with-gcc=gcc-4.9 用于解决checking whether the C compiler works... no 问题。
【解决方案3】:

我通过运行修复了它:

rvm install <ruby-version> --with-gcc=clang

替换为您要使用的版本

【讨论】:

    【解决方案4】:

    对于那些遇到同样问题的人,

    系统(按安装顺序)

    我已将 LDFLAGS 和 CPPFLAGS 设置为指向 Homebrew 安装,这导致了错误。我“取消链接”了 LDFLAGS 和 CPPFLAGS,运行了“rvm install 1.9.2”,一切正常。

    • rvm 安装 1.9.2

    【讨论】:

      【解决方案5】:

      尝试./configure --without-gcc 使用clang。

      【讨论】:

        【解决方案6】:

        我在小牛队,提供的答案对我不起作用。但是,更新我的 Xcode 版本并确保安装了命令行工具就可以了。

        【讨论】:

          【解决方案7】:

          使用系统知道的编译器来安装会容易很多

          1. rvm install ruby-1.9.3-p547 --with-gcc=`echo which gcc`
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2014-05-15
            • 2017-03-22
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2017-04-21
            相关资源
            最近更新 更多