【问题标题】:ERROR: Error installing ffi: ERROR: Failed to build gem native extension错误:安装 ffi 时出错:错误:无法构建 gem 原生扩展
【发布时间】:2011-12-12 17:54:54
【问题描述】:

安装了 DevKit 并重新运行了 ffi 安装……将其作为输出:

C:\Documents and Settings\******>gem install ffi
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing ffi:
        ERROR: Failed to build gem native extension.

        C:/Ruby192/bin/ruby.exe extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include... no
checking for rb_thread_blocking_region()... yes
checking for ruby_thread_has_gvl_p()... yes
checking for ruby_native_thread_p()... yes
checking for rb_thread_call_with_gvl()... yes
creating extconf.h
creating Makefile
make
C:/Ruby192/bin/ruby -e "puts 'EXPORTS', 'Init_ffi_c'"  > ffi_c-i386-mingw32.def
gcc -I. -IC:/Ruby192/include/ruby-1.9.1/i386-mingw32 -I/C/Ruby192/include/ruby-1
.9.1/ruby/backward -I/C/Ruby192/include/ruby-1.9.1 -I. -DRUBY_EXTCONF_H=\"extcon
f.h\"    -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -
Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-declaration-a
fter-statement   -o AbstractMemory.o -c AbstractMemory.c
In file included from AbstractMemory.c:28:0:
compat.h:65:20: warning: extra tokens at end of #ifndef directive
compat.h:69:24: warning: extra tokens at end of #ifndef directive
In file included from AbstractMemory.h:29:0,
                 from AbstractMemory.c:29:
Types.h:68:17: fatal error: ffi.h: No such file or directory
compilation terminated.
make: *** [AbstractMemory.o] Error 1 

Gem files will remain installed in C:/Ruby192/lib/ruby/gems/1.9.1/gems/ffi-1.0.1
0 for inspection.
Results logged to C:/Ruby192/lib/ruby/gems/1.9.1/gems/ffi-1.0.10/ext/ffi_c/gem_m
ake.out
_________________________________________________________________________________

不知道如何处理这个问题。请帮忙。

【问题讨论】:

    标签: ruby gem ffi


    【解决方案1】:

    gem 安装 ffi 失败,因为 gem 试图构建 libffi 的捆绑副本,由于假设 /usr/bin/env 存在并且 libffi 副本太旧而无法正常工作。

    但是,您可以针对系统 libffi 构建 ffi gem - 安装软件包:

    apt install clang make ruby-dev libffi-dev
    

    在那之后 ffi gem 应该构建:

    gem install ffi
    

    【讨论】:

      【解决方案2】:

      版本 1.0.10 在 Windows 上编译时出现问题。

      你可以使用 1.0.9

      gem install ffi --version='1.0.9'
      

      【讨论】:

      • +1 非常感谢,这帮助我在我的 Win7 机器上安装了中间人
      • ERROR: Error installing railties: ERROR: Failed to build gem native extension.
      • Windows 操作系统的 ruby​​ 和 ffi 版本是否发生错误?
      【解决方案3】:
      sudo apt-get install libffi-dev
      

      这对我有用

      【讨论】:

      • 这对我来说也适用于 Linux Mint 系统。这是对未来寻求者的提示(对于后代的价值):根据我的经验,不会自动安装的 gem 通常需要系统自己的包管理器来安装相关包的“开发”版本。
      【解决方案4】:

      请注意,如果您的捆绑程序不断尝试获取最新版本,那么安装 1.0.9 版是不够的。在您的 gemfile 中,您还需要输入:

      gem 'ffi', '1.0.9'
      

      这应该满足任何 gem 所要求的依赖关系,并让您启动并运行。

      【讨论】:

        【解决方案5】:

        当执行上述步骤时,可能会产生以下消息。

        $ bundle install
        Fetching source index for https://rubygems.org/
        You have requested:
        ffi = 1.0.9
        
        The bundle currently has ffi locked at 1.0.11.
        Try running `bundle update ffi`
        

        在这种情况下,您可以运行 'bundle update ffi' 命令,错误将得到解决。

        【讨论】:

          【解决方案6】:

          对我来说,修复程序按此顺序运行。我不确定所有相关的内容,但它确实有效:

          gem install ffi --version '1.0.9'
          

          上面失败了,但后来我可以成功运行:

          gem install bundler
          

          ...随后:

          gem install ffi
          

          ...获得最新版本(撰写本文时为 1.6.0)并成功安装。

          【讨论】:

          • 谢谢一百万!
          【解决方案7】:

          安装“osx-gcc-installer”对我有用:(osx 10.8)

          https://github.com/kennethreitz/osx-gcc-installer/downloads

          【讨论】:

          • 题目使用的环境是windows
          • 较新版本的 macOS 可能只需 xcode-select --install 即可获得编译器。
          【解决方案8】:

          帮助我:

          sudo apt install build-essential
          

          Debian 9

          Ruby 2.3.3

          【讨论】:

            【解决方案9】:

            你需要这个,

            apt-get install ruby2.2-dev
            

            【讨论】:

              【解决方案10】:

              复制自another post:

              正如Issue with installing ImageMagick and rmagick on Mountain Lion 中所述,ffi 似乎被配置为查找“gcc-4.2”,所以一旦我更新了我的Apple command line tools(我可能需要也可能不需要这样做),我创建了一个符号链接使 ffi 安装配置满意:

              sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
              

              【讨论】:

              • 安装 Apple CLI 工具后完美运行。
              【解决方案11】:

              对我来说,这通常有效

              gem install ffi -- --disable-system-libffi
              

              【讨论】:

              • 这在单独安装 gem 时有效,但在 ffibundle install 安装时无效。
              【解决方案12】:

              这对我有用 gem install ffi -- --disable-system-libffi 在 Ubuntu 20.04 (WSL) 上

              【讨论】:

              • 这在单独安装 gem 时有效,但在 ffibundle install 安装时无效。
              【解决方案13】:

              将 DevKit 放在 PATH 前面,然后从 Windows 命令提示符再次安装。

              【讨论】:

                【解决方案14】:

                我遇到了同样的问题。就我而言,我没有安装 DevKit,可以找到:http://rubyinstaller.org/downloads/。安装 DevKit 后,只需按照指令https://github.com/oneclick/rubyinstaller/wiki/development-kit 即可运行。

                【讨论】:

                  【解决方案15】:

                  我必须安装automake 才能让它工作。在 mac OSX 和 Ubuntu(CI 机器)上工作。

                  【讨论】:

                    【解决方案16】:

                    在 MacOS (Catalina) 上,运行 brew install libtool 首先为我解决了问题。

                    【讨论】:

                      猜你喜欢
                      • 2015-03-06
                      • 2014-12-28
                      • 2019-03-10
                      • 2014-08-18
                      • 2015-09-17
                      • 2014-04-22
                      • 1970-01-01
                      相关资源
                      最近更新 更多