天天看点

Windows下执行gem install 时ERROR: Failed to build gem native extension的解决办法.

最近在整移动端的自动化测试, 安装devkit 后 执行gem install json 老是报错:

Fetching: rdiscount-2.1.8.gem (100%)

Temporarily enhancing PATH to include DevKit...

Building native extensions.  This could take a while...

ERROR:  Error installing rdiscount:

        ERROR: Failed to build gem native extension.

    C:/Ruby200-x64/bin/ruby.exe extconf.rb

checking for random()... no

checking for srandom()... no

checking for rand()... yes

checking for srand()... yes

checking size of unsigned long... 4

checking size of unsigned int... failed

checking size of unsigned short... 2

no int with size 2

*** 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:/Ruby200-x64/bin/ruby

        --with-rdiscount-dir

        --without-rdiscount-dir

        --with-rdiscount-include

        --without-rdiscount-include=${rdiscount-dir}/include

        --with-rdiscount-lib

        --without-rdiscount-lib=${rdiscount-dir}/

Gem files will remain installed in C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rdisc

ount-2.1.8 for inspection.

Results logged to C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rdiscount-2.1.8/ext/ge

m_make.out

百般无奈, 上网查找解决办法,找打的大部分都是IOS系统或者是Linux系统的解决办法,苦恼很久,最后发现需要使用:

gem install json –v 1.8.3 -- --use-system-libraries

提供解决办法的人说是其libxml2与某些系统有冲突,附原帖地址如下:

http://stackoverflow.com/questions/24251494/nokogiri-gem-installation-error

继续阅读