我使用Ruby2.1.5在windows7上。
安装rbczmq
时出现以下错误:
C:\Users\namitk>gem install rbczmq
Building native extensions. This could take a while...
ERROR: Error installing rbczmq:
ERROR: Failed to build gem native extension.
C:/Ruby21-x64/bin/ruby.exe extconf.rb
checking for windows.h... yes
checking for winsock.h... yes
checking for main() in -lkernel32... yes
checking for main() in -lrpcrt4... yes
checking for main() in -lgdi32... yes
*** 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}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/Ruby21-x64/bin/ruby
--with-kernel32lib
--without-kernel32lib
--with-rpcrt4lib
--without-rpcrt4lib
--with-gdi32lib
--without-gdi32lib
extconf.rb:49:in `<main>': uninitialized constant GNU_CHAIN (NameError)
extconf failed, exit code 1
Gem files will remain installed in C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/rbczmq-1.7.8 for inspection.
Results logged to C:/Ruby21-x64/lib/ruby/gems/2.1.0/extensions/x64-mingw32/2.1.0/rbczmq-1.7.8/gem_make.out
即使gem install rbczmq -- --with-system-libs
也会出错。因此,在上面两个错误案例中,我尝试使用gem托管服务
rbczmq
然后我从它的git repo下载了source:https://github.com/methodmissing/rbczmq
然后我做了:
git submodule init
git submodule update
当我尝试将gemspec文件中的gem构建为gem build rbczmq.gemspec
时,从该源获取;发生了同样的uninitialized constant GNU_CHAIN
错误。
然后我使用系统库构建gem,如下所示,它成功了:
D:\rbczmq>gem build rbczmq.gemspec -- --with-system-libs
WARNING: description and summary are identical
WARNING: pessimistic dependency on minitest (~> 5.5.0, development) may be overly strict
if minitest is semantically versioned, use:
add_development_dependency 'minitest', '~> 5.5', '>= 5.5.0'
WARNING: pessimistic dependency on rake-compiler (~> 0.8.0, development) may be overly strict
if rake-compiler is semantically versioned, use:
add_development_dependency 'rake-compiler', '~> 0.8', '>= 0.8.0'
WARNING: See http://guides.rubygems.org/specification-reference/ for help
Successfully built RubyGem
Name: rbczmq
Version: 1.7.8
File: rbczmq-1.7.8.gem
正如您所见,当我在Windows上从源代码构建gem时,上面的步骤是成功的。但是当我将这个宝石安装为:
时会出现错误D:\rbczmq>gem install rbczmq-1.7.8.gem
ERROR: While executing gem ... (Errno::EINVAL)
Invalid argument @ dir_s_mkdir - C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/rbczmq-1.7.8/d:
从源代码构建gem时是否有任何错误?如何在Windows上解决上面提到的Invalid argument @ dir_s_mkdir
错误?
仅供参考:我获得了zeromq win64版本,用于匹配来自given rbczmq的https://binstar.org/minrk/zeromq/4.0.3/download/win-64%5Czeromq-4.0.3-1.tar.bz2中使用的zeromq