msys2下的ruby gem原生扩展失败

时间:2016-06-16 11:42:47

标签: ruby makefile rubygems msys2

我正在尝试安装几个宝石,其中一些需要构建原生扩展。

由于某些未知原因,自动生成的Makefile无法正常工作。 产生的错误是:

$ gem install ffi-yajl --verbose
 -IC:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/libyajl2-1.2.0/lib/libyajl2/vendored-libyajl2/include -march=x86-64 -mtune=generic -O2 -pipe -I/mingw64/include/ncurses -IC:/building/msys64/mingw64/lib/libffi-3.2.1/include
 -LC:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/libyajl2-1.2.0/lib/libyajl2/vendored-libyajl2/lib -L. -pipe
creating Makefile
generating encoder-x64-mingw32.def
make: *** No rule to make target '/C/msys64/mingw64/include/ruby-2.3.0/ruby.h', needed by 'encoder.o'.  Stop.
ERROR:  Error installing ffi-yajl:
        ERROR: Failed to build gem native extension.

    Building has failed. See above output for more information on the failure.
make failed, exit code 2

Gem files will remain installed in C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3 for inspection.
Results logged to C:/msys64/mingw64/lib/ruby/gems/2.3.0/extensions/x64-mingw32/2.3.0/ffi-yajl-2.2.3/gem_make.out
HEAD https://api.rubygems.org/api/v1/dependencies
200 OK
GET https://api.rubygems.org/api/v1/dependencies?gems=ffi-yajl
200 OK
Getting SRV record failed: DNS result has no information for _rubygems._tcp.api.rubygems.org
GET https://api.rubygems.org/api/v1/dependencies?gems=libyajl2
200 OK
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/LICENSE
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/README.md
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/Rakefile
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/bin/ffi-yajl-bench
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/ext/ffi_yajl/ext/dlopen/dlopen.c
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/ext/ffi_yajl/ext/dlopen/extconf.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/ext/ffi_yajl/ext/encoder/encoder.c
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/ext/ffi_yajl/ext/encoder/extconf.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/ext/ffi_yajl/ext/parser/extconf.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/ext/ffi_yajl/ext/parser/parser.c
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/benchmark.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/benchmark/MIT-LICENSE
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/benchmark/encode.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/benchmark/encode_json_and_marshal.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/benchmark/encode_json_and_yaml.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/benchmark/encode_profile.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/benchmark/http.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/benchmark/parse.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/benchmark/parse_json_and_marshal.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/benchmark/parse_json_and_yaml.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/benchmark/parse_profile.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/benchmark/parse_stream.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/benchmark/subjects/item.json
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/benchmark/subjects/ohai.json
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/benchmark/subjects/ohai.marshal_dump
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/benchmark/subjects/ohai.yml
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/benchmark/subjects/twitter_search.json
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/benchmark/subjects/twitter_stream.json
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/benchmark/subjects/unicode.json
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/encoder.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/ext.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/ext/.keep
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/ffi.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/ffi/encoder.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/ffi/parser.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/map_library_name.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/parser.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/platform.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/lib/ffi_yajl/version.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/spec/ffi_yajl/encoder_spec.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/spec/ffi_yajl/map_library_name_spec.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/spec/ffi_yajl/parser_spec.rb
C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/spec/spec_helper.rb
Building native extensions.  This could take a while...
current directory: C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/ext/ffi_yajl/ext/encoder
C:/msys64/mingw64/bin/ruby.exe -r ./siteconf20160616-3960-1kb305r.rb extconf.rb
current directory: C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/ext/ffi_yajl/ext/encoder
make "DESTDIR=" clean
current directory: C:/msys64/mingw64/lib/ruby/gems/2.3.0/gems/ffi-yajl-2.2.3/ext/ffi_yajl/ext/encoder
make "DESTDIR="

当我进入此文件夹并手动执行make时:

$ make
make: *** No rule to make target '/C/msys64/mingw64/include/ruby-2.3.0/ruby.h', needed by 'encoder.o'.  Stop.

更密切地检查问题:

$ ls -l /C/msys64/mingw64/include/ruby-2.3.0/ruby.h
-rw-r--r-- 1 User None 868 Jul 11  2012 /C/msys64/mingw64/include/ruby-2.3.0/ruby.h

如果我稍微修改Makefile(删除对象标题的依赖关系),那么显而易见:

$ make
compiling encoder.c
encoder.c:1:18: fatal error: ruby.h: No such file or directory
compilation terminated.
Makefile:238: recipe for target 'encoder.o' failed
make: *** [encoder.o] Error 1

手动运行命令(由make -n生成)不会产生任何错误并成功编译。不幸的是,我不能用这个hackery来构建gem。

接下来的问题是:为什么系统在make运行时找不到标题,但在直接使用gcc时却找到了? 我需要改变什么?

0 个答案:

没有答案