【问题标题】:Problems getting ruby-libvirt extensions to compile Mountain Lion获取 ruby​​-libvirt 扩展来编译 Mountain Lion 的问题
【发布时间】:2012-08-20 18:53:26
【问题描述】:

这周我买了一台新的 Mac,在安装这个 gem 时遇到了很大的问题。这在我的旧 Mac 上从来都不是问题,但在这台上似乎特别困难。

我已经通过 Homebrew、Xcode4.4(使用命令行工具)和 gcc4.2 安装了 libvirt。我已符号链接以使 gcc4.2 成为默认编译器。

gem install ruby-libvirt -v '0.4.0' 失败,因为它找不到标头

如果我将路径传递给头文件和库,如下所示:

ruby-libvirt -v '0.4.0' -V -- --with-libvirt-include=/usr/local/Cellar/libvirt/0.9.11.3/include/ --with-libvirt-lib=/usr/local/Cellar/libvirt/0.9.11.3/lib/

,它编译得很好,但在链接时失败并出现以下错误:

linking shared-object _libvirt.bundle ld: library not found for -lruby.1.9.1 collect2: ld returned 1 exit status make: *** [_libvirt.bundle] Error 1

我已经通过 RVM 安装了 Ruby 1.9.3,并且在安装其他本机扩展时没有遇到任何问题,所以我不明白为什么在这种情况下找不到 ruby​​ 库。

有人有什么想法吗?非常感谢您的帮助。

【问题讨论】:

  • RVM 是否安装了其他 ruby​​ 版本?执行rvm list 查找您在安装时遇到问题的文件夹。

标签: ruby osx-mountain-lion libvirt


【解决方案1】:

您只需要在安装包之前安装 libvirt。

brew install libvirt

【讨论】:

    【解决方案2】:

    要安装 gem,您需要安装 libvirt 库。使用“自制”(mac 的包管理器)

    brew install libvirt
    bundle install
    

    您得到的确切错误可能是:

    An error occurred while installing ruby-libvirt (0.4.0)
    

    【讨论】:

      【解决方案3】:

      我通过证明使用 brew 安装了外部 libvirt 来构建 ruby-libvirt-0.4.0/ext/libvirt

      这是我为成功安装 libvirt 所做的。

      1. brew install libvirt

      2. ruby extconf.rb --with-libvirt-include=/usr/local/include/libvirt --with-libvirt-lib=/usr/local/lib/libvirt

      3. gem install ruby-libvirt -v '0.4.0' -V -- --with-libvirt-include=/usr/local/Cellar/libvirt/1.1.4/include/libvirt --with-libvirt-lib=/usr/local/Cellar/libvirt/1.1.4/lib

      希望这会有所帮助。

      【讨论】:

      • 感谢您的帮助。 2017 年仍然有效。
      【解决方案4】:

      我终于解决了这个问题。事实证明,命令行工具没有正确安装。以下行需要添加到您的 .zshrc 文件(或适用于您选择的 shell 的任何内容):

      export PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:$PATH

      【讨论】:

        猜你喜欢
        • 2012-10-07
        • 1970-01-01
        • 1970-01-01
        • 2013-02-10
        • 2013-09-24
        • 1970-01-01
        • 2012-01-23
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多