2

My main database is a local mysql database, however I would like to occasionally connect to an Oracle database directly in my applications code.

The oracle database is hosted on another RHEL server.

I was unsuccessfull tried to install the ruby-OCI8 gem (ERROR: Failed to build gem native extension.)

I am wondering whether the oracle database has to be local in order to use this gem, or if there are any better ways of achieving this.

gem install ruby-oci8

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

/usr/bin/ruby extconf.rb
checking for load library path...
  LD_LIBRARY_PATH...
    checking /opt/instantclient... yes
  /opt/instantclient/libclntsh.so.11.1 looks like an instant client.
checking for cc... *** 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/bin/ruby
        --with-instant-client
        --without-instant-client
./oraconf.rb:562:in `check_cc': RuntimeError (RuntimeError)
        from ./oraconf.rb:549:in `init'
        from ./oraconf.rb:1001:in `initialize'
        from ./oraconf.rb:343:in `new'
        from ./oraconf.rb:343:in `get'
        from extconf.rb:18
ng
---------------------------------------------------
Error Message:
  C compiler doesn't work correctly.
Backtrace:
  ./oraconf.rb:562:in `check_cc'
  ./oraconf.rb:549:in `init'
  ./oraconf.rb:1001:in `initialize'
  ./oraconf.rb:343:in `new'
  ./oraconf.rb:343:in `get'
  extconf.rb:18
---------------------------------------------------
See:
 * http://ruby-oci8.rubyforge.org/en/HowToInstall.html
 * http://ruby-oci8.rubyforge.org/en/ReportInstallProblem.html

I checked the mkmf.log file:

 "gcc -o conftest -I. -I/usr/lib64/ruby/1.8/x86_64-linux -I.   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fs    tack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fno-strict-aliasing  -fPIC conftest.c  -L. -L/usr/lib64 -L.      -rdynamic -Wl,-export-dynamic     -lruby-static  -lpthread -lrt -ldl -lcrypt -lm   -lc"
  /usr/bin/ld: skipping incompatible /usr/lib/libruby-static.a when searching for -lruby-static
  /usr/bin/ld: cannot find -lruby-static
  collect2: ld returned 1 exit status
  checked program was:
  /* begin */
  1: int main() { return 0; }
  8 /* end */
Rumpleteaser
  • 4,142
  • 6
  • 39
  • 52
  • This has gotten away from the entire point of my initial question. I wanted to know if the OCI8 pluggin works for external databases, because I can 't seem to find anywhere to put the hostname – Rumpleteaser Dec 22 '10 at 05:19
  • "C compiler doesn't work correctly." seems to look like an issue. I tried downloading the source code and making it. – Rumpleteaser Dec 22 '10 at 05:53

3 Answers3

0

You can install the ruby-oci8 gem like below,

LD_LIBRARY_PATH=/local/home/soundar/instantclient_11_2 gem install ruby-oci8

Note: LD_LIBRARY_PATH is a enviroment variable set by oracle instant client directory path

Mohanraj
  • 4,056
  • 2
  • 22
  • 24
0

See if this blog post helps you in getting through the OCI gem install http://jessehu.wordpress.com/2008/07/03/ruby-oci8-gem-available-2/

Raghu
  • 2,543
  • 1
  • 19
  • 24
0

At first you need to install Oracle Instant Client - choose corresponding Linux 32-bit or 64-bit binaries. To be safe use older version 10.2.0.4 which I use in all my Ruby and Oracle projects. Install Basic, SDK and SQL*Plus packages.

Then include Oracle Instant Client installation directory in LD_LIBRARY_PATH environment variable so that Oracle Instant Client dynamic libraries would be in load path.

Then try to install ruby-oci8 gem.

Afterwards install activerecord-oracle_enhanced-adapter gem to be able to access Oracle database from ActiveRecord.

I have posted instructions how to install ruby-oci8 on Mac OS X - majority of this applies to Linux as well (DYLD_LIBRARY_PATH on Mac corresponds to LD_LIBRARY_PATH on Linux).

In addition I have created Sprinkle recipe for automated Oracle client installation on Linux - probably it is not the best way to start with this but in case you want to build automated server installation scripts then you can take a look on it.

Raimonds Simanovskis
  • 2,948
  • 1
  • 21
  • 17
  • I've unpacked our zip files, created all the symlinks required for future upgrades. exported the paths and put them in the bash profile. I have tested the oracle client and I am able to log onto a database and do a search. Gem still won't install. – Rumpleteaser Dec 22 '10 at 04:43