【问题标题】:Mountain Lion rvm install 1.8.7 x11 errorMountain Lion rvm 安装 1.8.7 x11 错误
【发布时间】:2012-07-24 18:37:46
【问题描述】:

更新到 Mountain Lion 后,我尝试安装 1.8.7,但出现错误。 X11 文件未找到,我安装了 Xquarkz,但没有任何改变。怎么了?

Fail to find [tclConfig.sh, tkConfig.sh]
Use MacOS X Frameworks.

Find Tcl/Tk libraries. Make tcltklib.so which is required by Ruby/Tk.
clang -I. -I../.. -I../../. -I../.././ext/tk -DHAVE_RB_SAFE_LEVEL -DHAVE_RB_HASH_LOOKUP -DHAVE_RB_PROC_NEW -DHAVE_RB_OBJ_TAINT -DHAVE_ST_PTR -DHAVE_ST_LEN -DRUBY_VERSION=\"1.8.7\" -DRUBY_RELEASE_DATE=\"2012-06-29\"  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -DWITH_TCL_ENABLE_THREAD=0 -fno-common -g -O2  -fno-common -pipe -fno-common   -c stubs.c
In file included from stubs.c:10:
/usr/include/tk.h:78:11: fatal error: 'X11/Xlib.h' file not found
#       include <X11/Xlib.h>
                ^
1 error generated.
make[1]: *** [stubs.o] Error 1
make: *** [all] Error 1

【问题讨论】:

标签: ruby rvm x11 osx-mountain-lion


【解决方案1】:

我成功地在 OSX 10.8.2 上进行了以下操作:

rvm install 1.8.7 --with-gcc=clang --without-tcl --without-tk

【讨论】:

  • 我是 Rails 开发人员,我需要 tk 和 tcl 做什么?那些不是 GUI 库吗? :) 感谢您的提示 - 它成功了!
  • 小心,ruby 1.8.7 与 clang 不完全兼容。当我尝试通过这种方法使用 bundler 和 rails 时,我在 OSX 10.8.4 上遇到了大量的分段错误,直到我回去先安装 GCC 4.2,然后重新安装 1.8.7。 This approach worked best for me,类似于@matteo-allesani 的回答
  • 谢谢!在 OSX 10.9 上安装 ruby​​ 1.8.7 可以使用该命令!
【解决方案2】:

如果您不需要 tcl 或 tk 并且正在使用 rbenv,这应该可以工作:

brew install https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb

CC=/usr/local/bin/gcc-4.2 CONFIGURE_OPTS="--without-tcl --without-tk" rbenv install 1.8.7-p358

【讨论】:

    【解决方案3】:

    即使在 X11 修复之后,我仍然收到此编译错误。

    compiling stubs.c
    In file included from stubs.c:16:
    /usr/include/tk.h:23:3: error: #error Tk 8.5 must be compiled with tcl.h from Tcl 8.5
    make[2]: *** [stubs.o] Error 1
    make[1]: *** [ext/tk/all] Error 2
    make: *** [build-ext] Error 2
    

    经过一番摸索后,我在 make 输出中注意到了这一行。

    Use ActiveTcl libraries (if available).
    

    原来我几年前安装了 ActiveTcl 8.4,但它从 /usr/include 获取 tk.h,它是 8.5 版。

    我不知道如何安全地卸载 ActiveTcl 和 ActiveTcl uninstall instructions weren't correct,但我确实安装了 ActiveTcl 8.5 并且解决了这个问题。 ActiveTcl Download这里。

    令人沮丧。无论如何,希望这对其他人有帮助。

    【讨论】:

      【解决方案4】:

      这是我的 .rvmrc 引导文件,希望对您有所帮助:

      if (uname -a | grep '12.0.0 Darwin' >/dev/null); then
          CC=/usr/local/bin/gcc-4.2 CPPFLAGS=-I/opt/X11/include rvm --install --create --disable-tcl --disable-tk use ree@gemset_name
      else
          rvm --install --create --disable-tcl --disable-tk use ree@gemset_name
      fi
      
      if ! which bundle >/dev/null; then
          gem install bundler --pre --no-ri --no-rdoc && bundle install
      fi
      
      
      if ! bundle check >/dev/null; then
          bundle install
      fi
      

      【讨论】:

        【解决方案5】:

        尝试通过http://xquartz.macosforge.org/landing/ 安装 X11 为编译器设置正确的 X11 库路径:

        export CPPFLAGS=-I/opt/X11/include
        

        然后尝试重新安装 ruby​​,传递给 gcc-4.2 所在的编译器:

        CC=/usr/local/bin/gcc-4.2 rvm reinstall 1.8.7
        

        没有CC,我遇到了很多分段错误。

        【讨论】:

        • 是的,出口就是其中之一。因为我使用的是 rbenv,所以不需要执行第二个命令。 :)
        • 你试过用 brew 安装 gcc 吗?命令是brew install apple-gcc42
        • 我得到这个:“错误:没有适用于 apple-gcc42 的公式”。我发现一些东西说我应该首先使用“brew tap homebrew/dupes”。在那之后,这个解决方案似乎奏效了!谢谢!
        • 另外,嗯,因为我永远不需要 tcl 和 tk :rvm reinstall 1.8.7 --without-tcl --without-tk
        • @ZainZafar -I 代表 Include,它在编译器中添加了以下包含目录
        猜你喜欢
        • 2012-07-24
        • 2012-11-11
        • 1970-01-01
        • 2013-04-13
        • 2012-09-18
        • 2013-03-21
        • 2012-12-12
        • 2012-12-11
        • 2012-10-18
        相关资源
        最近更新 更多