0

I'm trying to install sqlite3-ruby on Cygwin with gem install sqlite3-ruby -v x.x.x and I get the following error:

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

/usr/bin/ruby.exe extconf.rb
checking for fdatasync() in -lrt... *** 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.

Does anyone know how to install sqlite3 for Ruby on Rails on Cygwin. As I understand it the SQLite RubyGem isn't actually a *Ruby*Gem, it's a "*C*Gem", IOW it's written in C. This means it has to be compiled and linked to the Ruby interpreter when you install it, so any help?

Ian Wambai
  • 203
  • 3
  • 19
  • here is your answer http://stackoverflow.com/questions/43778/sqlite3-ruby-gem-failed-to-build-gem-native-extension – matanco May 15 '14 at 12:53
  • You say you're using `-v x.x.x`. You should make sure that version includes an windows build. For example, I have `sqlite 3 1.3.9 x86-mingw32` on my machine. I used `gem install sqlite3`. – Cereal May 15 '14 at 12:56
  • I get the same `ERROR: Failed to build gem native extension.` with every sqlite3-ruby gem I try to install – Ian Wambai May 15 '14 at 13:11

2 Answers2

0

So this isn't a complete solution as I don't have a windows box and cygwin handy but the error message suggests that the linux utility fdatasync can't be found.

The tools linux man page can be found here http://linux.die.net/man/2/fdatasync

Maybe find out if you have fdatasync installed correctly and try again.

Han Loong Liauw
  • 341
  • 2
  • 3
0

I ran into this issue just now – the first time I wanted to install a Ruby gem on my new Cygwin 64-bit system.

As I understand it the SQLite RubyGem isn't actually a RubyGem, it's a "CGem", IOW it's written in C. This means it has to be compiled and linked to the Ruby interpreter when you install it.

Cygwin actually provide a pre-compiled package which installs the sqlite3 gem files including the sqlite3_native.so linked library file. The name of the package is ruby-sqlite3 and you can install it using Cygwin’s Setup.exe. I personally like to use apt-cyg when possible (not always) so I installed the package using:

apt-cyg install ruby-sqlite3

This package installs the appropriate gem files as can be seen by running cygcheck -l ruby-sqlite3:

/usr/lib/gems/ruby/2.0.0/sqlite3-1.3.9/gem.build_complete
/usr/lib/gems/ruby/2.0.0/sqlite3-1.3.9/sqlite3/sqlite3_native.so
/usr/share/gems/gems/sqlite3-1.3.9/API_CHANGES.rdoc
/usr/share/gems/gems/sqlite3-1.3.9/ChangeLog.cvs
/usr/share/gems/gems/sqlite3-1.3.9/CHANGELOG.rdoc
/usr/share/gems/gems/sqlite3-1.3.9/faq/faq.rb
/usr/share/gems/gems/sqlite3-1.3.9/faq/faq.yml
/usr/share/gems/gems/sqlite3-1.3.9/Gemfile
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/constants.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/database.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/errors.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/pragmas.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/resultset.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/statement.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/translator.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/value.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/version.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3.rb
/usr/share/gems/gems/sqlite3-1.3.9/LICENSE
/usr/share/gems/gems/sqlite3-1.3.9/Manifest.txt
/usr/share/gems/gems/sqlite3-1.3.9/README.rdoc
/usr/share/gems/gems/sqlite3-1.3.9/tasks/faq.rake
/usr/share/gems/gems/sqlite3-1.3.9/tasks/gem.rake
/usr/share/gems/gems/sqlite3-1.3.9/tasks/native.rake
/usr/share/gems/gems/sqlite3-1.3.9/tasks/vendor_sqlite3
Anthony Geoghegan
  • 11,533
  • 5
  • 49
  • 56