Forum: Ruby SQLite3 Ruby 2.0 on Windows

Ead0c810163c355535e7c47c20955073?d=identicon&s=25 Scott Shaffer (mung)
on 2013-04-18 22:46
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/rubyin...

Installed in c:\ruby2.0.0p0

I installed the correct DevKit.

http://rubyforge.org/frs/download.php/76805/DevKit...

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...

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 Lavena

https://groups.google.com/forum/?fromgroups=#!topi...

Hope this helps someone else avoid what I had to go through.
249c7fd851c5c5ac5a1abdb756472ae1?d=identicon&s=25 Arup Rakshit (my-ruby)
on 2013-04-22 19:22
Thanks for sharing.
34a7615f38496a5dafbb3e6b721c435e?d=identicon&s=25 Mohit Sindhwani (Guest)
on 2013-05-10 07:36
(Received via mailing list)
On 19/4/2013 4:46 AM, Scott Shaffer 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.
249c7fd851c5c5ac5a1abdb756472ae1?d=identicon&s=25 Arup Rakshit (my-ruby)
on 2013-05-10 08:54
Scott Shaffer 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/rubyin...

> 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. :) :)


Thanks
14b5582046b4e7b24ab69b7886a35868?d=identicon&s=25 Joel Pearson (virtuoso)
on 2013-06-17 10:02
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:in `rescue 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:in `require'
        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:in `each'
        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:in `each'
        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:in `require'
        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:in `require'
        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:in `tap'
        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:in `require'
        from script/rails:6:in `<main>'

Is there something else that needs to be done for this to work within
Rails?
14b5582046b4e7b24ab69b7886a35868?d=identicon&s=25 Joel Pearson (virtuoso)
on 2013-06-17 11:05
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.
F55dcd01726fa40a9638187c7ca66a44?d=identicon&s=25 Kerry Perez (kerpie)
on 2013-07-21 23:59
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:in `try_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:in `block 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:in `open'
        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:in `open'
        from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:332:in `postpone'
        from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:890:in `checking_for'
        from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:1084:in `find_header'
        from extconf.rb:34:in `<main>'


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
Ead0c810163c355535e7c47c20955073?d=identicon&s=25 Scott Shaffer (mung)
on 2013-07-22 01:44
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
F55dcd01726fa40a9638187c7ca66a44?d=identicon&s=25 Kerry Perez (kerpie)
on 2013-07-22 01:51
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
14b5582046b4e7b24ab69b7886a35868?d=identicon&s=25 Joel Pearson (virtuoso)
on 2013-07-23 17:48
I posted a similar fix here:
https://www.ruby-forum.com/topic/4415126#new
Maybe that one will work for you.
Ead0c810163c355535e7c47c20955073?d=identicon&s=25 Scott Shaffer (mung)
on 2013-07-24 00:23
Hi Kerry, ok i see that now.

I needed to read the fine print ;)

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    <DIR>          .
04/18/2013  05:42 PM    <DIR>          ..
03/08/2013  03:37 PM               266 .metadata
04/18/2013  05:42 PM    <DIR>          bin
04/18/2013  05:42 PM    <DIR>          include
04/18/2013  05:42 PM    <DIR>          lib
04/18/2013  05:42 PM    <DIR>          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    <DIR>          .
04/18/2013  05:42 PM    <DIR>          ..
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
02b75a787428342159aab15aba06f734?d=identicon&s=25 Nenad P. (nenad_p)
on 2013-09-27 17:13
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
14b5582046b4e7b24ab69b7886a35868?d=identicon&s=25 Joel Pearson (virtuoso)
on 2013-10-04 18:13
Try doing it with the instructions and file I posted here:
https://www.ruby-forum.com/topic/4415126#1113976
Ead0c810163c355535e7c47c20955073?d=identicon&s=25 Scott Shaffer (mung)
on 2014-03-03 02:32
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?
39ca2d7a2722504ac2a7e9d70d3c2455?d=identicon&s=25 Michel (Guest)
on 2014-03-03 11:39
(Received via mailing list)
I didn't have any problem with the sqlite3 gem and Ruby 2.1.1 running on
ubuntu 12.04.
Regards,
Michel.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.