If you try to install (or update) the sqlite3 ruby gem on FreeBSD, you might get the following error:
sudo gem update sqlite3
Updating installed gems
Updating sqlite3
Fetching: sqlite3-1.3.5.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
/usr/local/bin/ruby18 extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal'
or 'yum install sqlite-devel' and check your shared library search path (the
location where your sqlite3 shared library is located).
*** 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:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/bin/ruby18
--with-sqlite3-dir
--without-sqlite3-dir
--with-sqlite3-include
--without-sqlite3-include=${sqlite3-dir}/include
--with-sqlite3-lib
--without-sqlite3-lib=${sqlite3-dir}/lib
--enable-local
--disable-local
Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/sqlite3-1.3.5 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/sqlite3-1.3.5/ext/sqlite3/gem_make.out
Nothing to update
The gem doesn’t include the correct locations to check for the sqlite3 headers, so we’ll have to tell it where to look ourself:
sudo CONFIGURE_ARGS="with-sqlite3-include=/usr/local/include" gem install sqlite3
Job done.
perfect. I’m working with installing tracks (http://getontracks.org) on FreeBSD. had to specify -v ‘1.3.4’ in my case, but still worked. thanks for the post!
Another way to fix this is to create a link:
ln -s /usr/local/include/sqlite3.h /usr/include/sqlite3.h
I needed to account for lib as well as include, so this worked for me:
CONFIGURE_ARGS=”with-sqlite3-dir=/usr/local” gem install sqlite3
This worked for me too, thank you for sharing!