SQLite-Ruby and Cygwin: Problem and Solution

E

Erik Veenstra

I had a problem installing SQLite-Ruby under Cygwin. But we
solved the problem...

Installing SQLite (sqlite-2.8.15.tar.gz) itself was no problem:
"./configure ; make ; make install" worked, as expected.

Installing SQLite-Ruby with "gem install sqlite-ruby-2.2.2.gem"
didn't work. It couldn't find the header files or library or
whatever of SQLite, although SQLite itself (the command line
tool) worked on an existing database.

I added just one single line to ext/extconf.rb ('dir_config(
"sqlite", "/usr/local" )'), compiled the whole thing and build
the gem. This one was indeed installable!

If you encountered the same problem, here is the "script".

Maybe something for the sqlite-ruby maintainers to correct?

Thanks for this great library. I like it.

The combination of SQLite as back end, WXRuby or RubyWebDialogs
as front end and Ruby itself for the logic, gives us a 100%
platform agnostic way of building applications. We at least
cover Linux, Windows and Cygwin. I don't know anything about OS
X, Solaris or other systems.

Oh, by the way: Did I already mention that both SQLite and
WXRuby (and RubyWebDialogs, of course) are detected and
embedded by RubyScript2Exe?...

gegroet,
Erik V.

----------------------------------------------------------------

$ tar xzf sqlite-ruby-2.2.2.tar.gz

$ cd sqlite-ruby-2.2.2/

$ cd ext/

$ vi extconf.rb # !!! Add: dir_config( "sqlite", "/usr/local" ) !!!

$ ruby extconf.rb
checking for main() in -lsqlite... yes
checking for sqlite.h... yes
checking for sqlite_open() in -lsqlite... yes
creating Makefile

$ make
gcc -g -O2 -I. -I/usr/lib/ruby/1.8/i386-cygwin
-I/usr/lib/ruby/1.8/i386-cygwin -I. -DHAVE_SQLITE_H -I/usr/local/includ
e -c sqlite-api.c
gcc -shared -s -Wl,--enable-auto-import,--export-all
-L"/usr/local/lib" -L"/usr/lib" -o sqlite_api.so sqlite-api.o -lr
uby -lsqlite -lsqlite -lcrypt

$ cd ..

$ touch README

$ gem build sqlite-ruby.gemspec
Attempting to build gem spec 'sqlite-ruby.gemspec'
Successfully built RubyGem
Name: sqlite-ruby
Version: 2.2.2
File: sqlite-ruby-2.2.2.gem

$ gem install sqlite-ruby-2.2.2.gem
Attempting local installation of 'sqlite-ruby-2.2.2.gem'
Building native extensions. This could take a while...
ruby extconf.rb install sqlite-ruby-2.2.2.gem
checking for main() in -lsqlite... yes
checking for sqlite.h... yes
checking for sqlite_open() in -lsqlite... yes
creating Makefile

make
make: Nothing to be done for `all'.

make install
install -c -p -m 0755 sqlite_api.so
/usr/lib/ruby/gems/1.8/gems/sqlite-ruby-2.2.2/lib
Successfully installed sqlite-ruby, version 2.2.2
Installing RDoc documentation for sqlite-ruby-2.2.2...
----------------------------------------------------------------
 
J

Jamis Buck

I had a problem installing SQLite-Ruby under Cygwin. But we
solved the problem...

Installing SQLite (sqlite-2.8.15.tar.gz) itself was no problem:
"./configure ; make ; make install" worked, as expected.

Installing SQLite-Ruby with "gem install sqlite-ruby-2.2.2.gem"
didn't work. It couldn't find the header files or library or
whatever of SQLite, although SQLite itself (the command line
tool) worked on an existing database.

I added just one single line to ext/extconf.rb ('dir_config(
"sqlite", "/usr/local" )'), compiled the whole thing and build
the gem. This one was indeed installable!

Non-standard install locations are problematic for compiled gems (like
sqlite-ruby). If you installed by hand, you could easily specify the
necessary "--with-sqlite-lib" and "--with-sqlite-include" parameters
to the install script, but with gems..

Chad, Jim, et. al.: is there a way (or could there be a way) to allow
the gem command to take optional parameters that get passed through
directly to the extconf.rb script?

- Jamis
 
E

Erik Veenstra

I added just one single line to ext/extconf.rb
Non-standard install locations are problematic for compiled
gems (like sqlite-ruby). If you installed by hand, you could
easily specify the necessary "--with-sqlite-lib" and
"--with-sqlite-include" parameters to the install script, but
with gems..

Non-standard location? "/usr/local/bin" and "/usr/local/lib"
seem pretty standard to me... That's what SQLite decided to
use, anyway.

Thanks.

gegroet,
Erik V.
 
J

Jamis Buck

Non-standard location? "/usr/local/bin" and "/usr/local/lib"
seem pretty standard to me... That's what SQLite decided to
use, anyway.

As compared to "/usr/bin" and "/usr/lib", I meant. By default, that's
what the mkmf.rb lib uses. You can pass parameters to specify
otherwise (--with-sqlite-lib, etc) to extconf.rb, but not to the gem
utility. Yet. To my knowledge. :)

- Jamis
 
J

Jim Weirich

Jamis Buck said:
Non-standard install locations are problematic for compiled gems (like
sqlite-ruby). If you installed by hand, you could easily specify the
necessary "--with-sqlite-lib" and "--with-sqlite-include" parameters
to the install script, but with gems..

Chad, Jim, et. al.: is there a way (or could there be a way) to allow
the gem command to take optional parameters that get passed through
directly to the extconf.rb script?

Just add the extconf.rb options to the gem install command after a "--".

See http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/106092
 
J

Jamis Buck

Jamis Buck said:

Just add the extconf.rb options to the gem install command after a "--".

See http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/106092

Wonderful! I should have known you gems guys would already have
figured this one out. :)

So, for future reference, if you are installing sqlite-ruby via gems
and you have sqlite installed in a location other than /usr, try:

gem install sqlite-ruby -- --with-sqlite-lib=/usr/local/lib
--with-sqlite-include=/usr/local/include

- Jamis
 
E

Erik Veenstra

So, for future reference, if you are installing sqlite-ruby
via gems and you have sqlite installed in a location other
than /usr, try:

gem install sqlite-ruby -- --with-sqlite-lib=/usr/local/lib
--with-sqlite-include=/usr/local/include

Worked flawlessly on another machine!

I still thing that /usr/local/[bin,lib,include] are common
places for installing software and that they have to be used
automatically. I bet you have good reasons for not doing so...
Please, enlighten me!

Thanks.

gegroet,
Erik V.
 
J

Jamis Buck

So, for future reference, if you are installing sqlite-ruby
via gems and you have sqlite installed in a location other
than /usr, try:

gem install sqlite-ruby -- --with-sqlite-lib=/usr/local/lib
--with-sqlite-include=/usr/local/include

Worked flawlessly on another machine!

I still thing that /usr/local/[bin,lib,include] are common
places for installing software and that they have to be used
automatically. I bet you have good reasons for not doing so...
Please, enlighten me!

No reason. I'm just arbitrary by nature. :)

Seriously, though, the reason it wasn't there already was because
(using Gentoo, as I do) things like sqlite on my machine get installed
into /usr/bin (etc.), and thus I've never had any problems with it.
And no one (until now) has reported problems.

So, assuming the change you recommended won't break *my* setup
(*grin*) I'll go ahead and make the change.

No, thank YOU. :)
gegroet,
Erik V.

- Jamis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top