Wednesday, November 26, 2008

Install sqlite3-ruby for Rails on Windows XP

A little bit of trouble when installing sqlite3-ruby on Windows. I get this error message:

C:\ruby\bin>gem install sqlite3-ruby
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
checking for fdatasync() in rt.lib... no
checking for sqlite3.h... no

nmake

Microsoft (R) Program Maintenance Utility   Version 1.50
Copyright (c) Microsoft Corp 1988-94. All rights reserved.

NMAKE : fatal error U1073: don't know how to make 'ruby.h'
Stop.


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

Here are the steps I followed to install it:
1. Download sqlite-3 and sqlitedll-3 from sqlite download.
2. Unzip the files to c:\ruby\bin. Total of 3 files, sqlite3.exe, sqlite3.dll, sqlite3.def.
3. In command line: gem install --version 1.2.3 sqlite3-ruby

C:\ruby\bin>gem install --version 1.2.3 sqlite3-ruby
Successfully installed sqlite3-ruby-1.2.3-x86-mswin32
1 gem installed
Installing ri documentation for sqlite3-ruby-1.2.3-x86-mswin32...
Installing RDoc documentation for sqlite3-ruby-1.2.3-x86-mswin32...
Enjoy...

19 comments:

Sean said...

The important point here is to use version 1.2.3.
Should you choose to build 1.2.4 yourself, in case you need some new features, remember that everything in the One-Click-Installer was built with MSVC60. If you build with MSVC8, errors in memory management will sneak up on you.

samdc said...

Sean, that's correct. This guide is a quick fix on making sqlite3 work. Thanks for the reminder.

Kat said...

Thank you very much for posting this reminder - it's kept me from tearing my hair all out! :)

Anonymous said...

Of all the posts I read on this topic this was by far the best solution out there. Thank you for taking the time to be helpful...Awesome!

madmax said...

Hi, I tried some solutions but nothing works. I've always the same : no such file to load.

I manage to install the rubygem sqlite3-ruby...

Steve Root said...

This didn't work for me at first.
Then, I did:
> gem uninstall sqlite3-ruby

Then, I took my command line to the directory where I unziped the sqlite files

> cd c:/ruby/bin

Then, I followed the instructions again:
> gem install sqlite3-ruby

and it worked - thanks!

jel63 said...

THIS WORKS!! Thanks so much!!!!

Carlos said...

Thanks a lot.

erick said...

Thanks...

Matthew said...

Thanks so much. Lifesaver.

Anonymous said...

thanks man, i was bothering with this for 2 befor i found your solution

Anonymous said...

Thanks m8 simple & clear solution.
This worked for me on a WinXP
;)

Will said...

This just sorted by sqlite prodlem on windows vista. Thanks a lot!

qwerty12 said...

Thank you, a lot. This worked when no other instructions did.

Anonymous said...

thanks for the post. Solved my issue

Anonymous said...

I have tried everything shown to install sqlite3 but it simply doesn't not work as I always get the following message "no definition for _wrap...". Can anybody help me please? Many thanks in advance

Successfully installed sqlite3-ruby-1.2.5-x86-mswin32
1 gem installed
Installing ri documentation for sqlite3-ruby-1.2.5-x86-mswin32...
Installing RDoc documentation for sqlite3-ruby-1.2.5-x86-mswin32...
No definition for _wrap_new_CallbackData

No definition for _wrap_CallbackData_proc_set

No definition for _wrap_CallbackData_proc_get

No definition for _wrap_CallbackData_proc2_set

No definition for _wrap_CallbackData_proc2_get

No definition for _wrap_CallbackData_data_set

No definition for _wrap_CallbackData_data_get

No definition for _wrap_sqlite3_libversion

No definition for _wrap_sqlite3_close

No definition for _wrap_sqlite3_last_insert_rowi
.......
.......
.......
.......
.......
.......

Anonymous said...

After struggling for quite some time, this was just the solve I needed.
Results are:
Ruby version -1.8.6 (i386-mswin32)
RubyGems version - 1.3.5
Rack version 1.0
Rails version 2.3.5
Active Record version 2.3.5
Active Resource version 2.3.5
Action Mailer version 2.3.5
Active Support version 2.3.5
Database adapter sqlite3
Database schema version 0

Anonymous said...

Many thanks - worked on Vista.

FrustratedCoder said...

i got the exe,dll and def files and put them in ruby\bin folder. Since i dont have internet on the box i am trying to install this in, i manually got the sqlite3-ruby gem (from gemcutter) and tried installing it. It didnt work so i got the sqlite3-ruby-1.2.3-x86-mswin32 gem file but it still gives me the same error, failed to build native extension.


C:\>gem install sqlite3-ruby-1.2.3-x86-mingw32.gem
Building native extensions. This could take a while...
ERROR: Error installing sqlite3-ruby-1.2.3-x86-mingw32.gem:
ERROR: Failed to build gem native extension.

C:/Ruby/bin/ruby.exe extconf.rb
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.3-x86-mingw32 for inspection.
Results logged to C:/Ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.3-x86-mingw32/
ext/sqlite3_api/gem_make.out

Please help.... m a total noob at this :(