SQLite-Ruby and Cygwin: Problem and Solution

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

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

···

On 02:15 Wed 26 Jan , Erik Veenstra wrote:

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

--
Jamis Buck
jamis_buck@byu.edu
http://jamis.jamisbuck.org
------------------------------
"I am Victor of Borge. You will be assimil-nine-ed."

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

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.

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

···

--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

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

- Jamis

···

On 02:45 Wed 26 Jan , Erik Veenstra wrote:

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

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

--
Jamis Buck
jamis_buck@byu.edu
http://jamis.jamisbuck.org
------------------------------
"I am Victor of Borge. You will be assimil-nine-ed."

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

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

···

On 03:32 Wed 26 Jan , Jim Weirich wrote:

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

--
Jamis Buck
jamis_buck@byu.edu
http://jamis.jamisbuck.org
------------------------------
"I am Victor of Borge. You will be assimil-nine-ed."

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.

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

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.

Thanks.

No, thank YOU. :slight_smile:

gegroet,
Erik V.

- Jamis

···

On 06:40 Wed 26 Jan , Erik Veenstra wrote:

--
Jamis Buck
jamis_buck@byu.edu
http://jamis.jamisbuck.org
------------------------------
"I am Victor of Borge. You will be assimil-nine-ed."