Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread


By: Luis Lavena
RE: sqlite3 gem does not install on solaris [ reply ]  
2010-08-26 03:47
Hello Dave,

Thank you for the information.

To avoid this get lost in a discussion thread, please open a Issue at GitHub for us to tackle on next release:

Thank you.

By: d c
sqlite3 gem does not install on solaris [ reply ]  
2010-08-26 02:12

It took me a little while to solve this, so I'm posting here to report the problem as well as hoping that others that have this issue will stumble here and save themselves some time :-) My apologies if this has been discussed before.

On a solaris 10 (sparc) host, ruby 1.9.1p243 is built with the sun studio compiler. When you run 'gem install sqlite3-ruby', the installation fails with the following output:

$ gem install sqlite3-ruby
Building native extensions. This could take a while...
ERROR: Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.

/home/dave/ruby/1.9.1-p243-sunwspro/bin/ruby extconf.rb
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:
/home/dave/ruby/1.9.1-p243-sunwspro/lib/ruby/1.9.1/mkmf.rb:362:in `try_do': The complier failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /home/dave/ruby/1.9.1-p243-sunwspro/lib/ruby/1.9.1/mkmf.rb:431:in `try_cpp'
from /home/dave/ruby/1.9.1-p243-sunwspro/lib/ruby/1.9.1/mkmf.rb:828:in `block in find_header'
from /home/dave/ruby/1.9.1-p243-sunwspro/lib/ruby/1.9.1/mkmf.rb:668:in `block in checking_for'
from /home/dave/ruby/1.9.1-p243-sunwspro/lib/ruby/1.9.1/mkmf.rb:274:in `block (2 levels) in postpone'
from /home/dave/ruby/1.9.1-p243-sunwspro/lib/ruby/1.9.1/mkmf.rb:248:in `open'
from /home/dave/ruby/1.9.1-p243-sunwspro/lib/ruby/1.9.1/mkmf.rb:274:in `block in postpone'
from /home/dave/ruby/1.9.1-p243-sunwspro/lib/ruby/1.9.1/mkmf.rb:248:in `open'
from /home/dave/ruby/1.9.1-p243-sunwspro/lib/ruby/1.9.1/mkmf.rb:270:in `postpone'
from /home/dave/ruby/1.9.1-p243-sunwspro/lib/ruby/1.9.1/mkmf.rb:667:in `checking_for'
from /home/dave/ruby/1.9.1-p243-sunwspro/lib/ruby/1.9.1/mkmf.rb:827:in `find_header'
from extconf.rb:28:in `<main>'

Gem files will remain installed in /home/dave/ruby/1.9.1-p243-sunwspro/lib/ruby/gems/1.9.1/gems/sqlite3-ruby-1.3.1 for inspection.
Results logged to /home/dave/ruby/1.9.1-p243-sunwspro/lib/ruby/gems/1.9.1/gems/sqlite3-ruby-1.3.1/ext/sqlite3/gem_make.out
*** END ERROR ***

At first I suspected that the installer simply could not find the sqlite3 header and library, which is indeed correct. However, doing a 'gem install sqlite3-ruby -- -with-sqlite3-dir=/opt/csw' yields the same error message, so I started digging further.

I looked in /home/dave/ruby/1.9.1-p243-sunwspro/lib/ruby/gems/1.9.1/gems/sqlite3-ruby-1.3.1/ext/sqlite3/extconf.rb and I found the culprit:

if RUBY_PLATFORM =~ /mswin/
$CFLAGS << ' -W3'
$CFLAGS << ' -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion' <<
' -Wmissing-noreturn -Winline'

Obviously this assumes that the platform is using GCC, which is not the case here. In fact, (and I could be wrong here.. please correct me if I am mistaken), ruby keeps the compiler and linker flags that were used to build the ruby interpreter in $RUBY_TOP/lib/ruby/1.9.1/mkmf.rb. I would assume that any native extensions that have to be built will pull the CFLAGS, LDFLAGS, etc from that file, so there should be no reason for these additions to CFLAGS within sqlite3-ruby's extconf.rb.

Sure enough, if I simply comment out those additions to CFLAGS in extconf.rb, the Makefile is generated, and I can carry on.

May I suggest that CFLAGS not simply add gcc-specific flags/optimizations?

Or, at the very least, if these optimziations are absolutely vital, can we at least have a check to see if we're using GCC or some_other_cc and only add these optimizations for GCC?