SQLite3 Ruby 2.0 on Windows

After having quite a time working out what needed to be done, I thought
I’d share how I got the sqlite3 gem installed on Windows under Ruby 2.0.

I installed Ruby 2.0 using RubyInstaller for Windows (32 bit).

http://rubyforge.org/frs/download.php/76804/rubyinstaller-2.0.0-p0.exe

Installed in c:\ruby2.0.0p0

I installed the correct DevKit.

http://rubyforge.org/frs/download.php/76805/DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe

Installed in c:\ruby2.0.0p0\devkit

I created a “knapsack” directory on my C: drive.

C:\knapsack

I downloaded file sqlite-3.7.15.2-x86-windows.tar.lzma and put it in the
knapsack directory.

http://packages.openknapsack.org/sqlite/sqlite-3.7.15.2-x86-windows.tar.lzma

I extracted that file using the bsdtar.exe program located in
devkit\mingw\bin. From the knapsack directory:

C:\knapsack>c:\ruby2.0.0p0\devkit\mingw\bin\bsdtar --lzma -xf
sqlite-3.7.15.2-x86-windows.tar.lzma

That created four directories (bin, include, lib, share)

I then ran gem install as follows:

C:\knapsack>ruby -v
ruby 2.0.0p0 (2013-02-24) [i386-mingw32]

C:\knapsack>gem install sqlite3 --platform=ruby –
–with-opt-dir=C:/Knapsack
Fetching: sqlite3-1.3.7.gem (100%)
Temporarily enhancing PATH to include DevKit…
Building native extensions with: ‘–with-opt-dir=C:/Knapsack’
This could take a while…
Successfully installed sqlite3-1.3.7
Parsing documentation for sqlite3-1.3.7
unable to convert “\x90” from ASCII-8BIT to UTF-8 for
lib/sqlite3/sqlite3_native.so, skipping
Installing ri documentation for sqlite3-1.3.7
1 gem installed

C:\knapsack>irb
DL is deprecated, please use Fiddle
irb(main):001:0> require ‘sqlite3’
=> true
irb(main):002:0> SQLite3::SQLITE_VERSION
=> “3.7.15.2”
irb(main):003:0> exit

C:\knapsack>

And all was well with the world, finally. Whew!

HT: Luis L.

https://groups.google.com/forum/?fromgroups=#!topic/rubyinstaller/gedIaMryCFQ

Hope this helps someone else avoid what I had to go through.

Thanks for sharing.

On 19/4/2013 4:46 AM, Scott S. wrote:

After having quite a time working out what needed to be done, I thought
I’d share how I got the sqlite3 gem installed on Windows under Ruby 2.0.

Awesome, thanks!

Best Regards,
Mohit.
10/5/2013 | 1:35 PM.

Scott S. wrote in post #1106196:

After having quite a time working out what needed to be done, I thought
I’d share how I got the sqlite3 gem installed on Windows under Ruby 2.0.

I installed Ruby 2.0 using RubyInstaller for Windows (32 bit).

http://rubyforge.org/frs/download.php/76804/rubyinstaller-2.0.0-p0.exe

Hope this helps someone else avoid what I had to go through.

If you installed Rail in Windows ever,then such step by step
installation tutorial,if you share,that will be good enough for the
newly started beginner. :slight_smile: :slight_smile:

Thanks

I appear to have fixed this by accident.
It turns out that when I ran “bundle install” to set up the Rails
project, it installed a different version, which is was going to by
default. Uninstalling the unwanted version fixed this.

I followed these steps using Ruby 2.0.0p195 [i386-mingw32] on Windows 7.

When I use ‘require sqlite’ in irb that works:

SQLite3::SQLITE_VERSION
=> “3.7.15.2”

However, when I try to use “rails s” in a rails project folder, I get
this:

C:\rails\timesheet>rails s
C:/Ruby200/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.7-x86-mingw32/lib/sqlite3.rb:6:i
n require': cannot load such file -- sqlite3/sqlite3_native (LoadError) from C:/Ruby200/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.7-x86-mingw32/lib/s qlite3.rb:6:inrescue in <top (required)>’
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.7-x86-mingw32/lib/s
qlite3.rb:2:in <top (required)>' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runti me.rb:72:inrequire’
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runti
me.rb:72:in block (2 levels) in require' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runti me.rb:70:ineach’
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runti
me.rb:70:in block in require' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runti me.rb:59:ineach’
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runti
me.rb:59:in require' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler.rb:13 2:inrequire’
from C:/rails/timesheet/config/application.rb:7:in <top (required)>' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/comma nds.rb:53:inrequire’
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/comma
nds.rb:53:in block in <top (required)>' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/comma nds.rb:50:intap’
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/comma
nds.rb:50:in <top (required)>' from script/rails:6:inrequire’
from script/rails:6:in `’

Is there something else that needs to be done for this to work within
Rails?

Hi Scott,

I tried what you did, but when I do this part:

C:\knapsack>gem install sqlite3 --platform=ruby –
–with-opt-dir=C:/Knapsack

I still get this:

C:\knapsack>gem install sqlite3 --platform=ruby –
–with-opt-dir=C:/knapsack
Temporarily enhancing PATH to include DevKit…
Building native extensions with: ‘–with-opt-dir=C:/knapsack’
This could take a while…
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.

C:/Ruby200/bin/ruby.exe extconf.rb --with-opt-dir=C:/knapsack

checking for sqlite3.h… *** 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
–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/bin/ruby
–with-sqlite3-dir
–without-sqlite3-dir
–with-sqlite3-include
–without-sqlite3-include=${sqlite3-dir}/include
–with-sqlite3-lib
–without-sqlite3-lib=${sqlite3-dir}/
–enable-local
–disable-local
C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:430:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:561:intry_cpp’
from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:1085:in block in find_header' from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:891:inblock in
checking_for’
from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:336:in block (2 levels) in postpone' from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:306:inopen’
from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:336:in block in postpone' from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:306:inopen’
from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:332:in postpone' from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:890:inchecking_for’
from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:1084:in find_header' from extconf.rb:34:in

Gem files will remain installed in
C:/Ruby200/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.7 for inspection.
Results logged to
C:/Ruby200/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.7/ext/sqlite3/gem_make.out

and here is my mkmf.log file

"gcc -o conftest.exe
-I C:/Ruby200/include/ruby-2.0.0/i386-mingw32
-I C:/Ruby200/include/ruby-2.0.0/ruby/backward
-I C:/Ruby200/include/ruby-2.0.0 -I.
-I C:/knapsack/include -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501
-D_FILE_OFFSET_BITS=64 -O3 -fno-omit-frame-pointer -fno-fast-math -g
-Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long
-Wno-missing-field-initializers -Wunused-variable -Wpointer-arith
-Wwrite-strings -Wdeclaration-after-statement
-Wimplicit-function-declaration conftest.c -L.
-L C:/Ruby200/lib
-L C:/knapsack/lib -L. -lmsvcrt-ruby200 -lshell32 -lws2_32
-limagehlp -lshlwapi "
checked program was:
/* begin */
1: #include “ruby.h”
2:
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char *argv)
6: {
7: return 0;
8: }
/
end */

I’m using ruby 2.0.0p247 (2013-06-27) [i386-mingw32] and my devkit
version is mingw64-32-4.7.2. Could you please help me with this? Thanks

Hi Scott,

I’m using the version rubyinstaller.org recommends, I’m not using the 64
bit Dev kit, in the download page says:

Ruby 2.0.0: mingw64-32-4.7.2
Ruby 2.0.0 x64 (64bits): mingw64-64-4.7.2

I posted a similar fix here:
https://www.ruby-forum.com/topic/4415126#new
Maybe that one will work for you.

Hi Kerry,

You’re using 32-bit Ruby 2.0 and 64 bit Dev Kit?

First I’d try getting on the same version.

Regards

Hi Kerry, ok i see that now.

I needed to read the fine print :wink:

This seems to be the relevant line:

checking for sqlite3.h… *** extconf.rb failed ***

Is this the only version of Ruby you have installed?

What are the contents of your knapsack directory?

ruby 2.0.0p0 (2013-02-24) [i386-mingw32]

Directory of C:\knapsack

04/18/2013 05:42 PM .
04/18/2013 05:42 PM …
03/08/2013 03:37 PM 266 .metadata
04/18/2013 05:42 PM bin
04/18/2013 05:42 PM include
04/18/2013 05:42 PM lib
04/18/2013 05:42 PM share
04/18/2013 05:39 PM 452,569
sqlite-3.7.15.2-x86-windows.tar.lzma
2 File(s) 452,835 bytes

Did you extract the tar.lzma file?

In the include directory:

Directory of C:\knapsack\include

04/18/2013 05:42 PM .
04/18/2013 05:42 PM …
03/08/2013 03:32 PM 343,763 sqlite3.h
03/08/2013 03:32 PM 24,158 sqlite3ext.h
2 File(s) 367,921 bytes

Do you have those files?

regards

Try doing it with the instructions and file I posted here:
https://www.ruby-forum.com/topic/4415126#1113976

Is it just me or does this have nothing whatsoever to do with Ruby 2.x?

The other day I downloaded and installed Ruby 1.9.3-p545 and I ran into
similar installation issues for the sqlite3 gem that I had under Ruby
2.0.

Is this then an issue with the gem itself, regardless of Ruby version?

Followed the instructions but it says sqlite3.h is missing ?
Any help ? Thanks!

C:\knapstack>gem install sqlite3 --platform=ruby –
–with-opt-dir=C:/knapsack
Temporarily enhancing PATH to include DevKit…
Building native extensions with: ‘–with-opt-dir=C:/knapsack’
This could take a while…
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.

C:/Ruby200/bin/ruby.exe extconf.rb --with-opt-dir=C:/knapsack

checking for sqlite3.h… no
sqlite3.h is missing. Install SQLite3 from http://www.sqlite.org/ first.
*** 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

I didn’t have any problem with the sqlite3 gem and Ruby 2.1.1 running on
ubuntu 12.04.
Regards,
Michel.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs