I'm trying to get the ruby-odbc gem installed on a Mac OS X 10.9 under ruby-1.9.3-p547 for use with a rails 2.3.12 application which connects to a SAP system over ODBC.
Environment
Situation
The gem system fails the build when executing
gem install ruby-odbc
complaining about not being able to find sql.h
as in
ERROR: sql.h not found
I then attempted to tell the gem installation environment where the ODBC headers were located via
gem install ruby-odbc -- --with-odbc-dir=/usr/local/iODBC
But this fails still with the following messages (basically still can't find the sql.h header files).
At this point - stuck as unable to get the gem built
This could take a while...
ERROR: Error installing ruby-odbc:
ERROR: Failed to build gem native extension.
/Users/grantsayer/.rvm/rubies/ruby-1.9.3-p547/bin/ruby extconf.rb --with-odbc-dir=/usr/local/iODBC --with-odbc-include=/usr/local/iODBC/include
checking for version.h... no
checking for sql.h... no
*** 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
--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=/Users/grantsayer/.rvm/rubies/ruby-1.9.3-p547/bin/ruby
--with-odbc-dir
--with-odbc-include=${odbc-dir}/include
--with-odbc-lib
--without-odbc-lib=${odbc-dir}/lib
ERROR: sql.h not found
extconf failed, exit code 1
Have resolved the issue. The key was the command to install the gem as
gem install ruby-odbc -- --with-odbc-dir=/usr/local/iODBC/
The key steps prior to this was to re-install the software stack as per the steps
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ \curl -sSL https://get.rvm.io | bash -s stable
rvm install ruby-1.9.3
There are multiple versions, with the Mac OX version provided as a DMG file which provides for the installation of the Driver Manager, within Applications, and the header files necessary for building the ruby-odbc gem
http://www.iodbc.org/dataspace/iodbc/wiki/iODBC/Downloads#Mac%20OS%20X
The ruby-odbc gem is described at Ruby ODBC. This describes the building of the raw source, but the gem install ecosystem will get the sources and build.
gem install ruby-odbc -- --with-odbc-dir=/usr/local/iODBC/
The important part is the path to the installed headers and libraries, which are placed into /usr/local/iODBC via the iODBC install.
Success is when you have the usual happy message that the gem was installed as shown below:
gem install ruby-odbc -- --with-odbc-dir=/usr/local/iODBC/
Building native extensions with: '--with-odbc-dir=/usr/local/iODBC/'
This could take a while...
Successfully installed ruby-odbc-0.99995
Enclosing class/module 'Modbc' for class Object not known
Enclosing class/module 'Modbc' for class Environment not known
Enclosing class/module 'Modbc' for class Database not known
Enclosing class/module 'Modbc' for class Statement not known
Enclosing class/module 'Modbc' for class Column not known
Enclosing class/module 'Modbc' for class Parameter not known
Enclosing class/module 'Modbc' for class DSN not known
Enclosing class/module 'Modbc' for class Driver not known
Enclosing class/module 'Modbc' for class Error not known
Enclosing class/module 'Modbc' for class Date not known
Enclosing class/module 'Modbc' for class Time not known
Enclosing class/module 'Modbc' for class TimeStamp not known
Installing ri documentation for ruby-odbc-0.99995
1 gem installed
I had similar problem on macOs Sierra 10.12
What I did:
brew install libiodbc
Then check version of installed package (should be like libiodbc-3.52.12) if different change in the following command:
gem install ruby-odbc -- --with-odbc-dir=/usr/local/Cellar/libiodbc/3.52.12/
Good luck.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With