# SQLite3 Ruby 2.0 on Windows

**URL:** <https://www.ruby-forum.com/t/sqlite3-ruby-2-0-on-windows/228352>\
**Category:** Ruby\
**Created:** [April 18, 2013, 10:46pm UTC](https://www.ruby-forum.com/t/sqlite3-ruby-2-0-on-windows/228352 "2013-04-18T22:46:21Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![asherwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c67d28/32.png) [@asherwood](https://www.ruby-forum.com/u/asherwood)\
**Post date:** [April 18, 2013, 10:46pm UTC](https://www.ruby-forum.com/t/sqlite3-ruby-2-0-on-windows/228352/1 "2013-04-18T22:46:21Z")

</div>

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

> **[openknapsack.org](http://ww38.packages.openknapsack.org/sqlite/sqlite-3.7.15.2-x86-windows.tar.lzma)**
>
> This domain may be for sale!

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](https://groups.google.com/forum/?fromgroups=#!topic/rubyinstaller/gedIaMryCFQ)

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

---

<div class="post-metadata">

**Author:** ![asherwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c67d28/32.png) [@asherwood](https://www.ruby-forum.com/u/asherwood)\
**Post date:** [April 22, 2013, 7:22pm UTC](https://www.ruby-forum.com/t/sqlite3-ruby-2-0-on-windows/228352/2 "2013-04-22T19:22:27Z")

</div>

Thanks for sharing.

---

<div class="post-metadata">

**Author:** ![asherwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c67d28/32.png) [@asherwood](https://www.ruby-forum.com/u/asherwood)\
**Post date:** [May 10, 2013, 7:36am UTC](https://www.ruby-forum.com/t/sqlite3-ruby-2-0-on-windows/228352/3 "2013-05-10T07:36:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![asherwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c67d28/32.png) [@asherwood](https://www.ruby-forum.com/u/asherwood)\
**Post date:** [May 10, 2013, 8:54am UTC](https://www.ruby-forum.com/t/sqlite3-ruby-2-0-on-windows/228352/4 "2013-05-10T08:54:12Z")

</div>

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](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. 🙂 🙂

Thanks

---

<div class="post-metadata">

**Author:** ![asherwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c67d28/32.png) [@asherwood](https://www.ruby-forum.com/u/asherwood)\
**Post date:** [June 17, 2013, 11:05am UTC](https://www.ruby-forum.com/t/sqlite3-ruby-2-0-on-windows/228352/5 "2013-06-17T11:05:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![asherwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c67d28/32.png) [@asherwood](https://www.ruby-forum.com/u/asherwood)\
**Post date:** [June 17, 2013, 10:02am UTC](https://www.ruby-forum.com/t/sqlite3-ruby-2-0-on-windows/228352/6 "2013-06-17T10:02:32Z")

</div>

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 `’

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

---

<div class="post-metadata">

**Author:** ![asherwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c67d28/32.png) [@asherwood](https://www.ruby-forum.com/u/asherwood)\
**Post date:** [July 21, 2013, 11:59pm UTC](https://www.ruby-forum.com/t/sqlite3-ruby-2-0-on-windows/228352/7 "2013-07-21T23:59:26Z")

</div>

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 `’

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

---

<div class="post-metadata">

**Author:** ![asherwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c67d28/32.png) [@asherwood](https://www.ruby-forum.com/u/asherwood)\
**Post date:** [July 22, 2013, 1:51am UTC](https://www.ruby-forum.com/t/sqlite3-ruby-2-0-on-windows/228352/8 "2013-07-22T01:51:13Z")

</div>

Hi Scott,

I’m using the version [rubyinstaller.org](http://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

---

<div class="post-metadata">

**Author:** ![asherwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c67d28/32.png) [@asherwood](https://www.ruby-forum.com/u/asherwood)\
**Post date:** [July 23, 2013, 5:48pm UTC](https://www.ruby-forum.com/t/sqlite3-ruby-2-0-on-windows/228352/9 "2013-07-23T17:48:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![asherwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c67d28/32.png) [@asherwood](https://www.ruby-forum.com/u/asherwood)\
**Post date:** [July 22, 2013, 1:44am UTC](https://www.ruby-forum.com/t/sqlite3-ruby-2-0-on-windows/228352/10 "2013-07-22T01:44:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![asherwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c67d28/32.png) [@asherwood](https://www.ruby-forum.com/u/asherwood)\
**Post date:** [July 24, 2013, 12:23am UTC](https://www.ruby-forum.com/t/sqlite3-ruby-2-0-on-windows/228352/11 "2013-07-24T00:23:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![asherwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c67d28/32.png) [@asherwood](https://www.ruby-forum.com/u/asherwood)\
**Post date:** [October 4, 2013, 6:13pm UTC](https://www.ruby-forum.com/t/sqlite3-ruby-2-0-on-windows/228352/12 "2013-10-04T18:13:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![asherwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c67d28/32.png) [@asherwood](https://www.ruby-forum.com/u/asherwood)\
**Post date:** [March 3, 2014, 2:32am UTC](https://www.ruby-forum.com/t/sqlite3-ruby-2-0-on-windows/228352/13 "2014-03-03T02:32:43Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![asherwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c67d28/32.png) [@asherwood](https://www.ruby-forum.com/u/asherwood)\
**Post date:** [September 27, 2013, 5:13pm UTC](https://www.ruby-forum.com/t/sqlite3-ruby-2-0-on-windows/228352/14 "2013-09-27T17:13:26Z")

</div>

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/](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

---

<div class="post-metadata">

**Author:** ![asherwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c67d28/32.png) [@asherwood](https://www.ruby-forum.com/u/asherwood)\
**Post date:** [March 3, 2014, 11:39am UTC](https://www.ruby-forum.com/t/sqlite3-ruby-2-0-on-windows/228352/15 "2014-03-03T11:39:41Z")

</div>

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