Compiling DBD::Oracle for Red Hat Linux with the Oracle Instant Client

From my work intrablog, Tuesday, April 29th, 2008. I tested today and the same patch is necessary.

It’s annoying how much harder this is than the MySQL driver…

  1. Download these RPMs from Oracle’s Instant Client for Linux page:Instant Client Package – Basic: All files required to run OCI, OCCI, and JDBC-OCI applications Instant Client Package – SDK: Additional header files and an example makefile for developing Oracle applications with Instant Client [just for future fun] Instant Client Package – ODBC: Additional libraries for enabling ODBC applications
  2. Installify them,
    $ sudo rpm -ivh oracle-instantclient-*.rpm
  3. Get DBD::Oracle
    sudo cpan
    cpan> look DBD::Oracle
  4. Look at README.linux.txt
  5. Set up the environment
    export ORACLE_HOME=/usr/lib/oracle/
    export ORACLE_DSN="DBI:Oracle:host=myhost;sid=MYINSTANCE"  # remember to quote the ;
    export ORACLE_USERID=myusername/mypassword
  6. I had to patch the Makefile.PL (sent changes to the maintainer) to find the header files with a longer “client_version_full”:
    # diff -u Makefile.PL Makefile.PL.dist
    --- Makefile.PL 2008-07-31 10:53:00.253634000 -0800
    +++ Makefile.PL.dist    2008-07-31 10:51:49.327631000 -0800
    @@ -1538,7 +1538,7 @@
         if (!$client_version_full) {
            print "I'm having trouble finding your Oracle version number... trying harder\n"
                unless $force_version;
    -       if ( $OH =~ m![^\d\.]((?:8|9|1\d)\.\d+\.\d+<strong>(\.\d+)?</strong>)! ) { #decode it from $OH if possible
    +       if ( $OH =~ m![^\d\.]((?:8|9|1\d)\.\d+\.\d+)! ) { #decode it from $OH if possible
                $client_version_full = $1;
            elsif ( "$OH/" =~ m!\D(8|9|10)(\d)(\d?)\D!) { # scary but handy
  7. Install normally:
    perl Makefile.PL
    make test # a few minor failures
    make install