安装ffi ruby​​ gem时找不到ffi.h [英] Can't Find ffi.h When Installing ffi ruby gem

查看:292
本文介绍了安装ffi ruby​​ gem时找不到ffi.h的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ruby版本2.2.4p230

Ruby version 2.2.4p230

RubyGem版本2.7.2

RubyGem version 2.7.2

已安装Ruby-devel和lib64ffi-devel.

Ruby-devel and lib64ffi-devel installed.

使用了64位OpenMandriva 3.0,urpmi和rpmdrake.

64-bit OpenMandriva 3.0, urpmi and rpmdrake used.

目标:安装指南针,但首先需要gem ffi.

Goal: to install compass, but the gem ffi is needed first.

在过去的两天里,我一直在艰难地搜寻互联网,我感到非常沮丧...由于对较早的ncurses的依赖,我无法安装较早版本的ruby.我觉得替换ncurses会打开一罐讨厌的蠕虫.

I have scoured the internet so hard for the last two days and I'm so stumped... It's impossible for me to install an earlier version of ruby because of the dependency for an older ncurses. I feel like replacing ncurses would open a can of nasty worms.

但是...我也完全接受指南针替代方案,可以以某种方式移植/复制config.rb项目文件,以便指南针和其他sass编译器都可以运行. (这是工作,我们不会在不久的将来更改sass构建器).

However... I am also completely open to a compass alternative, where the config.rb project files could be somehow ported / copied so both compass and this other sass compiler could operate. (this is for work and we're not changing the sass builder any time soon).

/usr/share/gems/gems/ffi-1.9.18/ext/ffi_c完全存在,该目录中有一个ffi.c文件,但在附近找不到任何ffi.h文件.绝望的片刻,我触摸了该目录中的ffi.h,并在运行gem install时将其删除. ;)我会尝试复制别人的libs看看是否可行.

/usr/share/gems/gems/ffi-1.9.18/ext/ffi_c totally exists, there is an ffi.c file in that directory but can't find any ffi.h file in the vicinity. In a moment of desperation I touched ffi.h in that dir and when I ran gem install it removed it. ;) I would try taking a copy of someone else's libs to see if that works.

基本上可以用任何方法来完成此工作,而不会破坏我的其余程序包.我不将红宝石用于其他任何用途,仅用于指南针.

Basically any way to get this working without breaking the rest of my packages. I don't use ruby for anything else, just compass.

以下是输出:

# sudo gem install ffi
Building native extensions. This could take a while...
ERROR:  Error installing ffi:
    ERROR: Failed to build gem native extension.

current directory: /usr/share/gems/gems/ffi-1.9.18/ext/ffi_c
/usr/bin/ruby -r ./siteconf20171110-17988-1lodsok.rb extconf.rb
checking for ffi.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib64
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/bin/$(RUBY_BASE_NAME)
    --with-ffi_c-dir
    --without-ffi_c-dir
    --with-ffi_c-include
    --without-ffi_c-include=${ffi_c-dir}/include
    --with-ffi_c-lib
    --without-ffi_c-lib=${ffi_c-dir}/lib64
    --with-libffi-config
    --without-libffi-config
    --with-pkg-config
    --without-pkg-config
/usr/share/ruby/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /usr/share/ruby/mkmf.rb:587:in `try_cpp'
    from /usr/share/ruby/mkmf.rb:1060:in `block in have_header'
    from /usr/share/ruby/mkmf.rb:911:in `block in checking_for'
    from /usr/share/ruby/mkmf.rb:351:in `block (2 levels) in postpone'
    from /usr/share/ruby/mkmf.rb:321:in `open'
    from /usr/share/ruby/mkmf.rb:351:in `block in postpone'
    from /usr/share/ruby/mkmf.rb:321:in `open'
    from /usr/share/ruby/mkmf.rb:347:in `postpone'
    from /usr/share/ruby/mkmf.rb:910:in `checking_for'
    from /usr/share/ruby/mkmf.rb:1059:in `have_header'
    from extconf.rb:16:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /usr/lib64/gems/ruby/ffi-1.9.18/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/share/gems/gems/ffi-1.9.18 for inspection.
Results logged to /usr/lib64/gems/ruby/ffi-1.9.18/gem_make.out

任何帮助表示赞赏!

推荐答案

您的错误消息显示:

/usr/share/ruby/mkmf.rb:456:在"try_do"中:编译器无法生成可执行文件. (RuntimeError) 您必须先安装开发工具.

/usr/share/ruby/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first.

这就是解决问题的方法:

And that's how you can solve it:

xcode-select --install

(但请事先确保xcode-select -p将路径返回到稳定的Xcode版本,例如Xcode 10)

(but make sure beforehand that xcode-select -p is returning the path to a stable Xcode version, like Xcode 10)

另请参见 https://github.com/ffi/ffi/issues/647.

这篇关于安装ffi ruby​​ gem时找不到ffi.h的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆