SQLIte3 DL driver deprecated, how to use native?

Hi.

I’m writing what’s pretty much my first piece of code using Ruby. Very
happy
with it so far and have managed to cobble together a bit of code to
archive
a large amount of text (basically a message board archive) into a sqlite
database. And it works! One thing is intriguing me though. I’m seeing an
error generated by the line:

db = SQLite3::Database.new( ‘test.db’ )

The warning message is:

The DL driver for sqlite3-ruby is deprecated and will be removed
in a future release. Please update your installation to use the
Native driver.

I’ve spent the best part of two days looking for how to get the system
to
use the native driver. I’m running on Solaris 10 (sparc). Sqlite3
resides
under /usr/local/bin (and it’s libraries under /usr/local/lib ). I’ve
installed SWIG and reinstalled the sqlite3-ruby gem. Nothing seems to
make a
difference. Am I missing a trick here? It may be that this isn’t the
right
place to ask a question like this, although there seemed to be a fair
amount
of SQLite3 related queries in the archive. If this is the wrong place,
feel
free to tell me to sod off, I won’t be offended :wink:

Here’s how I install the sqlite3-ruby gem, and the output - any clues
here?
It would seem the native driver is being compiled, should I be doing
something other than using SQLite3::Database.new to choose it?

bash-3.00# gem install sqlite3-ruby
Need to update 16 gems from http://gems.rubyforge.org

complete
Select which gem to install for your platform (sparc-solaris2.10)

  1. sqlite3-ruby 1.2.1 (mswin32)
  2. sqlite3-ruby 1.2.1 (ruby)
  3. sqlite3-ruby 1.2.0 (mswin32)
  4. sqlite3-ruby 1.2.0 (ruby)
  5. sqlite3-ruby 1.1.0 (mswin32)
  6. sqlite3-ruby 1.1.0 (ruby)
  7. sqlite3-ruby 1.0.1 (ruby)
  8. sqlite3-ruby 1.0.1 (mswin32)
  9. sqlite3-ruby 1.0.0 (mswin32)
  10. sqlite3-ruby 1.0.0 (ruby)
  11. sqlite3-ruby 0.9.0 (ruby)
  12. sqlite3-ruby 0.9.0 (mswin32)
  13. sqlite3-ruby 0.6.0 (ruby)
  14. sqlite3-ruby 0.5.0 (ruby)
  15. Cancel installation

2
Building native extensions. This could take a while…
make: *** No rule to make target ruby.h', needed by sqlite3_api_wrap.o’.
Stop.
make: *** No rule to make target ruby.h', needed by sqlite3_api_wrap.o’.
Stop.
ruby extconf.rb install sqlite3-ruby
checking for sqlite3.h… yes
checking for sqlite3_open() in -lsqlite3… no

make

make install

make clean
Successfully installed sqlite3-ruby-1.2.1
Installing ri documentation for sqlite3-ruby-1.2.1…

lib/sqlite3/database.rb:638:65: Skipping require of dynamic string:
“sqlite3/driver/#{driver.to_s.downcase}/driver”

lib/sqlite3/database.rb:643:59: Skipping require of dynamic string:
“sqlite3/driver/#{d.downcase}/driver”
Installing RDoc documentation for sqlite3-ruby-1.2.1…

lib/sqlite3/database.rb:638:65: Skipping require of dynamic string:
“sqlite3/driver/#{driver.to_s.downcase}/driver”

lib/sqlite3/database.rb:643:59: Skipping require of dynamic string:
“sqlite3/driver/#{d.downcase}/driver”

Regards

Hi,

On Wed, Aug 29, 2007 at 07:50:33PM +0900, Eddie Catflap wrote:

The warning message is:
place to ask a question like this, although there seemed to be a fair amount
of SQLite3 related queries in the archive. If this is the wrong place, feel
free to tell me to sod off, I won’t be offended :wink:

Here’s how I install the sqlite3-ruby gem, and the output - any clues here?
It would seem the native driver is being compiled, should I be doing
something other than using SQLite3::Database.new to choose it?

[…]

Building native extensions. This could take a while…
make: *** No rule to make target ruby.h', needed bysqlite3_api_wrap.o’.
Stop.
make: *** No rule to make target ruby.h', needed bysqlite3_api_wrap.o’.

It would appear that rubygems cannot find your ruby.h for your ruby
installation, which it needs to build the native driver. I have not
installed ruby on Solaris myself, but is there a ruby.h in the directory
printed out with this:

ruby -rrbconfig -e 'puts ::Config::CONFIG["includedir"]'

enjoy,

-jeremy

Hi Jeremy

Thanks for the quick reply!

On 8/29/07, Jeremy H. [email protected] wrote:

Hi,

It would appear that rubygems cannot find your ruby.h for your ruby
installation, which it needs to build the native driver. I have not
installed ruby on Solaris myself, but is there a ruby.h in the directory
printed out with this:

ruby -rrbconfig -e 'puts ::Config::CONFIG["includedir"]'

You are onto something there - there isn’t:

-bash-3.00$ ruby -rrbconfig -e ‘puts ::Config::CONFIG[“includedir”]’
/usr/local/include
-bash-3.00$ ls /usr/local/include
c++ libcharset.h ncurses readline zconf.h
iconv.h localcharset.h python2.5 sqlite3.h zlib.h

However I have found it under /usr/local/lib/ruby/1.8/sparc-solaris2.10
/ruby.h

I’m guessing the ruby package installed on this system (from
Sunfreeware.comby the looks of things) sticks the header files in a
strange place. Adding
this dir to PATH or LD_LIBRARY_PATH wasn’t enough to resolve the
problem.
I’ll do a bit more digging around, thanks for pointing me in the right
direction - I’ll update this once I get the answer.

Here’s how I resolved this and managed to get the native driver to
compile,
for anyone who’s interested.

I went down the route of removing all gems, rubygems and ruby itself,
then
reinstalled ruby from source (not the prebuilt package from
sunfreeware).
Then reinstalled rubygems and all the gems I had before.

The sqlite3-ruby gem however would not even compile the ruby driver once
I’d
done that! Completed failed - So I downloaded the source and went down
the
ruby setup.rb config route:

bash-3.00# ruby setup.rb config
—> lib
—> lib/sqlite3
—> lib/sqlite3/driver
—> lib/sqlite3/driver/dl
<— lib/sqlite3/driver/dl
—> lib/sqlite3/driver/native
<— lib/sqlite3/driver/native
<— lib/sqlite3/driver
<— lib/sqlite3
<— lib
—> ext
—> ext/sqlite3_api
/usr/local/bin/ruby
/var/tmp/sqlite3-ruby-1.2.1/ext/sqlite3_api/extconf.rb
checking for sqlite3.h… yes
checking for sqlite3_open() in -lsqlite3… no
—> ext/sqlite3_api/win32
<— ext/sqlite3_api/win32
<— ext/sqlite3_api
<— ext

The next step failed however:

bash-3.00# ruby setup.rb setup
—> lib
—> lib/sqlite3
—> lib/sqlite3/driver
—> lib/sqlite3/driver/dl
<— lib/sqlite3/driver/dl
—> lib/sqlite3/driver/native
<— lib/sqlite3/driver/native
<— lib/sqlite3/driver
<— lib/sqlite3
<— lib
—> ext
—> ext/sqlite3_api
make
make: *** No rule to make target ruby.h', needed by sqlite3_api_wrap.o’.
Stop.
'system make ’ failed
Try ‘ruby setup.rb --help’ for detailed usage.

After much wailing and gnashing of teeth I came across the following
url:

http://readlist.com/lists/sqlite.org/sqlite-users/0/4442.html

Where a Mr Stephen Fitch described his (similar, but not exact) problem
with
the package on Solaris 10. His solution was to

export LD_OPTIONS=“-lposix4”

before running ruby setup.rb config etc, so I tried it… and it worked!

bash-3.00# ruby setup.rb config
—> lib
—> lib/sqlite3
—> lib/sqlite3/driver
—> lib/sqlite3/driver/dl
<— lib/sqlite3/driver/dl
—> lib/sqlite3/driver/native
<— lib/sqlite3/driver/native
<— lib/sqlite3/driver
<— lib/sqlite3
<— lib
—> ext
—> ext/sqlite3_api
/usr/local/bin/ruby
/var/tmp/sqlite3-ruby-1.2.1/ext/sqlite3_api/extconf.rb
checking for sqlite3.h… yes
checking for sqlite3_open() in -lsqlite3… yes
creating Makefile
—> ext/sqlite3_api/win32
<— ext/sqlite3_api/win32
<— ext/sqlite3_api
<— ext
bash-3.00# ruby setup.rb setup
—> lib
—> lib/sqlite3
—> lib/sqlite3/driver
—> lib/sqlite3/driver/dl
<— lib/sqlite3/driver/dl
—> lib/sqlite3/driver/native
<— lib/sqlite3/driver/native
<— lib/sqlite3/driver
<— lib/sqlite3
<— lib
—> ext
—> ext/sqlite3_api
make
gcc -I. -I. -I/usr/local/lib/ruby/1.8/sparc-solaris2.10
-I/var/tmp/sqlite3-
ruby-1.2.1/ext/sqlite3_api -DHAVE_SQLITE3_H -I/usr/local/include -fPIC
-g
-O2 -c sqlite3_api_wrap.c
gcc -shared -L’/usr/local/lib’ -Wl,-R’/usr/local/lib’
-L’/usr/local/lib’
-Wl,-R’/usr/local/lib’ -o sqlite3_api.so sqlite3_api_wrap.o -lsqlite3
-ldl
-lcrypt -lm -lc
—> ext/sqlite3_api/win32
<— ext/sqlite3_api/win32
<— ext/sqlite3_api
<— ext

After that it was just a case of ruby setup.rb install, test it out
and… no
more ‘deprecated’ warnings. So thanks to Mr Fitch, wherever you may be.