I’ve been learning Ruby and wanted to use SQLite for an application, but there didn’t seem to be a pre-built package for Windows that would drop in and work with the quick-install distribution of Ruby for Windows. Read on for steps I took to get it to work, or just unpack this archive into your ruby 1.8 install directory and skip to the examples/reference section of the README file in the sqlite-ruby package.
The source for SQLite is found at the main SQLite web site, I built it from the source using MS VC6. I think this archive is the same resulting DLL, but I wanted to do it myself to make sure. The SQLite Wiki has instructions for generating a .def file from that archive, use “lib /def:sqlite.def”. Remember to run vcvars32.bat to get the VC6 environment variables set up in a command prompt window if you’re going to try that. I created a Win32 DLL project, added all of the .c files in the source package except for tclsqlite.c, and turned off pre-compiled headers. At this point it built with some warnings.
The sqlite-ruby package installs if you’ve got ruby installed somewhere that doesn’t have spaces in its path, which I didn’t because I’d installed into C:\Program Files\ruby instead of the default C:\ruby. I un/re-installed ruby to fix that problem.
I moved the VC6-generated sqlite.{lib|dll} files into the lib and bin directories, respectively, of the ruby install directory. I ran the “ruby extconf.rb; make; make install” commands given in the README file in a command prompt window. There were two errors the first time I tried, indicating I was missing symbols sqlite_version and sqlite_encoding. I copy/pasted it from the main.c of the SQLite source into the sqlite.c of the sqlite-ruby package and then the install commands worked fine, as well as the examples.
I generated a sqlite.tgz archive so that I wouldn’t have to repeat the above steps on every machine I wanted to have ruby/sqlite combination running.
This all worked with the following versions of these packages: Ruby 1.8.0, SQLite 2.8.12, sqlite-ruby 1.0.