简体   繁体   English

sqlite3-ruby gem:无法构建gem原生扩展

[英]sqlite3-ruby gem: Failed to build gem native extension

Update: Check out this follow-up question: Gem Update on Windows - is it broken? 更新:查看此后续问题: Windows上的Gem更新 - 它是否已损坏?


On Windows, when I do this: 在Windows上,当我这样做时:

gem install sqlite3-ruby

I get the following error: 我收到以下错误:

Building native extensions.  This could take a while...
ERROR:  Error installing sqlite3-ruby:
        ERROR: Failed to build gem native extension.

c:/ruby/bin/ruby.exe extconf.rb install sqlite3-ruby --platform Win32
checking for fdatasync() in rt.lib... no
checking for sqlite3.h... no

nmake
'nmake' is not recognized as an internal or external command,
operable program or batch file.


Gem files will remain installed in c:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4 for inspection.
Results logged to c:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/gem_make.out

Same thing happens with the hpricot gem . 同样的事情发生在hpricot gem上 I seem to remember these gems installed just fine on < 1.0 gems, but now I'm on 1.2.0, things have gone screwy. 我似乎记得这些宝石在<1.0宝石上安装得很好,但现在我在1.2.0上,事情变得棘手了。

I have also tried this: 我也试过这个:

gem install sqlite3-ruby --platform Win32

Needless to say, this doesn't work either (same error) 不用说,这也不起作用(同样的错误)

Does anyone know what is going on here and how to fix this? 有谁知道这里发生了什么以及如何解决这个问题?


Update: Check out this follow-up question: Gem Update on Windows - is it broken? 更新:查看此后续问题: Windows上的Gem更新 - 它是否已损坏?

As Nathan suggests, this does appear to be related to the fact that the latest versions of the sqlite3-ruby and hpricot gems don't appear to have Windows versions. 正如Nathan所暗示的那样,这似乎与sqlite3-ruby和hpricot gems的最新版本似乎没有Windows版本的事实有关。 Here's what to do when faced with this situation (note, the name of the gem is automatically wildcarded, so you can type just sql and get a list of all gems beginning with sql ): 这是面对这种情况时要做的事情(注意,gem的名称是自动通配符,所以你可以只键入sql并获取以sql开头的所有gem的列表):

$ gem list --remote --all sqlite

*** REMOTE GEMS ***

sqlite (2.0.1, 2.0.0, 1.3.1, 1.3.0, 1.2.9.1, 1.2.0, 1.1.3, 1.1.2, 1.1.1, 1.1)
sqlite-ruby (2.2.3, 2.2.2, 2.2.1, 2.2.0, 2.1.0, 2.0.3, 2.0.2)
sqlite3-ruby (1.2.4, 1.2.3, 1.2.2, 1.2.1, 1.2.0, 1.1.0, 1.0.1, 1.0.0, 0.9.0, 0.6.0, 0.5.0)

Then you can choose the version you would like to install: 然后,您可以选择要安装的版本:

gem install sqlite3-ruby -v 1.2.3

To successfully install hpricot, I did this: 为了成功安装hpricot,我这样做了:

gem install hpricot -v 0.6

Annoyingly, doing a gem update tries to update the gems to their latest, broken-on-Windows, versions. 令人讨厌的是,做gem update尝试将gem update为最新的,破碎的Windows版本。 When the update routine encounters an error, it ditches you out of the whole process. 当更新例程遇到错误时,它会使您退出整个过程。 There's a (hacky) solution to this problem here . 有一个(哈克)解决了这个问题在这里

So, is this issue a bug in gems? 那么,这个问题是宝石中的一个错误吗? Should gems not automatically detect the platform and install the latest compatible version? 宝石是不是会自动检测平台并安装最新的兼容版本?

I had the same problem on Ubuntu, this solved the problem for me: 我在Ubuntu上遇到了同样的问题,这解决了我的问题:

http://newsgroups.derkeiler.com/Archive/Comp/comp.lang.ruby/2008-08/msg00339.html http://newsgroups.derkeiler.com/Archive/Comp/comp.lang.ruby/2008-08/msg00339.html

first from sqlite.org( http://www.sqlite.org/download.html ) 首先来自sqlite.org( http://www.sqlite.org/download.html
download -> 下载 - >
Precompiled Binaries: sqlite-dll-win32-x86-3071700.zip 预编译的二进制文件: sqlite-dll-win32-x86-3071700.zip
and Source Code: sqlite-autoconf-3071700.tar.gz 源代码: sqlite-autoconf-3071700.tar.gz
then extract as: 然后提取为:

-include
    --sqlite3.h
    --sqlite3ext.h
-lib
    --shell.c
    --sqlite3.c
    --sqlite3.def
    --sqlite3.dll

last install gem like: 最后安装宝石像:

gem install sqlite3 --platform=ruby -- --with-sqlite3-include=path\to\include  
 --with-sqlite3-lib=path\to\lib --no-ri --no-rdoc

Good luck! 祝好运!

Is it possible that the newest version has not yet been ported to Win32 yet? 是否有可能最新版本尚未移植到Win32? Since this particular gem does have bindings to compiled code, it would require a platform-specific gem. 由于这个特定的gem确实绑定了编译代码,因此需要一个特定于平台的gem。 If I force installation of version 1.2.3 rather than the current 1.2.4, the platform-specific version does install, but when I allow gem to try to install the current version, I get the generic 1.2.4 version (in the gems library folder, it lacks the -x86-mswin32 suffix that the other sqlite3-ruby folders have in their names. 如果我强制安装版本1.2.3而不是当前的1.2.4,那么特定于平台的版本会安装,但是当我允许gem尝试安装当前版本时,我会得到通用的1.2.4版本(在宝石中)库文件夹,它缺少其他sqlite3-ruby文件夹名称中的-x86-mswin32后缀。

Maybe someone else can answer how gem handles platform specific gems. 也许其他人可以回答宝石处理平台特定宝石的方式。 Are separate gems uploaded for each platform and the gem software selects which one to pull down? 是否为每个平台上传了单独的宝石,宝石软件会选择哪一个下拉?

I had the same problem on Windows and I have installe MinGW http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/MinGW%205.1.6/MinGW-5.1.6.exe/download and the problem has gone :-) 我在Windows上遇到了同样的问题,我安装了MinGW http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/MinGW%205.1.6/MinGW-5.1.6.exe/download和问题走了 :-)

C:>gem install hpricot Successfully installed hpricot-0.8.2-x86-mswin32 1 gem installed Installing ri documentation for hpricot-0.8.2-x86-mswin32... Installing RDoc documentation for hpricot-0.8.2-x86-mswin32... C:> gem install hpricot安装成功安装了hpricot-0.8.2-x86-mswin32 1 gem安装hpricot-0.8.2-x86-mswin32的ri文档...安装hpricot-0.8.2-x86-mswin32的RDoc文档。 ..

C:>gem install ruby-postgres Successfully installed ruby-postgres-0.7.1.2006.04.06-x86-mswin32 1 gem installed Installing ri documentation for ruby-postgres-0.7.1.2006.04.06-x86-mswin32... Installing RDoc documentation for ruby-postgres-0.7.1.2006.04.06-x86-mswin32... C:> gem install ruby​​-postgres成功安装ruby-postgres-0.7.1.2006.04.06-x86-mswin32安装1个gem安装ruby-postgres-0.7.1.2006.04.06-x86-mswin32的ri文档...安装RDoc文档红宝石的Postgres-0.7.1.2006.04.06 86 mswin32 ...

I also ran into this problem. 我也遇到了这个问题。 It's worth knowing that the difference between 1.2.3 and 1.2.4 is not significant. 值得了解的是,1.2.3和1.2.4之间的差异并不显着。 Here are the 1.2.4. 这是1.2.4。 release notes: 发行说明:

Release Name: 1.2.4 发布名称:1.2.4

Notes: This release only updates the generated C file to reflect the compatibility changes that were made to the SWIG file. 注意:此版本仅更新生成的C文件,以反映对SWIG文件所做的兼容性更改。 Binary builds (eg, Windows) are not affected, and need no update. 二进制版本(例如,Windows)不受影响,无需更新。 In general, you will not need this update unless you are using a version of Ruby prior to 1.8.6. 通常,除非您使用1.8.6之前的Ruby版本,否则不需要此更新。 (source: 1.2.4. release notes ) (来源: 1.2.4。发行说明

Hope that helps others! 希望能帮到别人!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM