Installing the Ruby ODBC Module
Locomotive on Mac OS X
Prebuilt binaries
If you do not wish to build from source, or do not have Xcode installed, we have provided a few binaries of the ODBC module, odbc.bundle, which you can copy into the appropriate location (e.g. /Applications/Locomotive2/Bundles/rails112.locobundle/i386/lib/ruby/site_ruby/1.8/i686-darwin8.6.1/).
- Download the relevant Ruby ODBC Bridge for your machine type (precompiled and downloaded from ch-werner) --
-
gunzipthe downloaded bundle, and place in the relevant location --- G4 or G5 -- =/Applications/Locomotive2/Bundles/rails112.locobundle/powerpc/lib/ruby/site_ruby/1.8/powerpc-darwin7.9.0/odbc.bundle=
- Intel -- =/Applications/Locomotive2/Bundles/rails112.locobundle/i386/lib/ruby/site_ruby/1.8/i686-darwin8.6.1/odbc.bundle=
Building from source: preliminary note
You need to ensure that the correct version of ruby is in your PATH. If you run `ruby extconf.rb' (below) in an ordinary Terminal window, the chances are your system-wide installation will be picked-up, from /usr/bin/ruby. If you're using Locomotive, we recommend using its Terminal (either Application/Open Terminal, or shortcut Apple+T), which sets PATH correctly. Then proceed using that terminal window as follows:
All platforms
Download the tarball and unpack. You'll end up with a directory like:
zsh, pizza 5:01PM ruby-odbc-0.998/ % ls COPYING MANIFEST doc/ test/ ChangeLog README extconf.rb test.rb GPL cqgen.rb odbc.c utf8/ zsh, pizza 5:01PM ruby-odbc-0.998/ %
Here you run the extconf.rb script:
zsh, pizza 5:01PM ruby-odbc-0.998/ % ruby extconf.rb \
--with-iodbc=/usr/local/iODBC
checking for sql.h... yes
checking for sqlext.h... yes
checking for SQLTCHAR... yes
checking for odbcinst.h... no
checking for SQLAllocConnect() in -lodbc... no
checking for SQLAllocConnect() in -liodbc... yes
creating Makefile
zsh, pizza 5:06PM ruby-odbc-0.998/ %
It's wise to check the resultant Makefile. For example, it should probably have calls to iodbc-config on the CFLAGS and LDFLAGS lines:
CFLAGS = -fno-common -g -Os -pipe -fno-common -pipe -fno-common -pipe \ -fno-common `iodbc-config --cflags` ... LDSHARED = cc $(RC_CFLAGS) -bundle `iodbc-config --libs`
Then it's just a normal make + make install to complete installation:
zsh, pizza 5:08PM ruby-odbc-0.998/ % make gcc -fno-common -g -Os -pipe -fno-common -pipe -fno-common -pipe \ -fno-common `iodbc-config --cflags` -I. \ -I/usr/lib/ruby/1.8/powerpc-darwin8.0 -I/usr/lib/ruby/1.8/powerpc-darwin8.0 \ -I. -DHAVE_SQL_H -DHAVE_SQLEXT_H -DHAVE_TYPE_SQLTCHAR -c odbc.c cc -bundle `iodbc-config --libs` -L"/usr/lib" -o odbc.bundle odbc.o \ -lruby -liodbc -lpthread -ldl -lobjc zsh, pizza 5:08PM ruby-odbc-0.998/ % sudo make install install -c -p -m 0755 odbc.bundle /usr/lib/ruby/site_ruby/1.8/powerpc-darwin8.0 zsh, pizza 5:08PM ruby-odbc-0.998/ %
Testing
To test it, run
zsh% ruby -e 'require "odbc"'
If it doesn't do anything, it's loaded correctly.
| Attachment | Type | Action | Size | Date | Owner | Comment |
|---|---|---|---|---|---|---|
| odbc.bundle.gz | application/x-gzip | Delete | 66K | 2006-09-29 07:34:34 | UDADataSpaceBot | odbc.bundle.ppc.g5.gz |
| odbc.bundle.i386.gz | application/x-gzip | Delete | 65K | 2006-09-29 07:33:09 | UDADataSpaceBot | odbc.bundle.i386.gz |
| odbc.bundle.ppc.g4.gz | application/x-gzip | Delete | 67K | 2006-09-29 07:34:02 | UDADataSpaceBot | odbc.bundle.ppc.g4.gz |