24

Could someone guide me how to install the Perl DBD::Oracle module?

Here is what I have done so far:

  • Platform: RHEL 5.8 64 bit
  • Installed Perl DBI package
  • Installed Oracle Instant client for Linux 64 bit (basi + sdk + sqlplus component for the instant client
  • Have set the correct $ORACLE_HOME and $LD_LIBRARY_PATH
  • Then when I do perl Makefile.pl it fails with the following error:

    I'm having trouble finding your Oracle version number... trying harder
    
    WARNING: I could not determine Oracle client version so I'll just
    default to version 8.0.0.0. Some features of DBD::Oracle may not work.
    Oracle version based logic in Makefile.PL may produce erroneous results.
    You can use "perl Makefile.PL -V X.Y.Z" to specify a your client version.
    
    Oracle version 8.0.0.0 (8.0)
    DBD::Oracle no longer supports Oracle client versions before 9.2
     Try a version before 1.25 for 9 and 1.18 for 8! at Makefile.PL line 271.
    
  • The instant client version: 11.1.0

  • The DBD::Oracle version is 1.44

If you have installed successfully with the Oracle instant client, then could you please let me know what am I missing?

Is it possible to install DBD::Oracle without using the Oracle instant client?

4 Answers 4

47
  • Install if missing ExtUtils-MakeMaker module (sudo yum install perl-ExtUtils-MakeMaker)
  • Install Perl DBI module ($ yum install perl-DBI)
  • Manually install below three RPMs for Oracle instant client (from Instant Client Downloads for Linux x86-64. The example is for v11.2.0.3.0-1: adapt the commands below to the actual version.)

    oracle-instantclient11.2-basic-11.2.0.3.0-1
    oracle-instantclient11.2-devel-11.2.0.3.0-1
    oracle-instantclient11.2-sqlplus-11.2.0.3.0-1
    

I am using 64 bit Linux box, so select your RPM filenames accordingly. Something like sudo yum -y install oracle-instantclient*rpm should do)

  • set below variables:

    export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib
    export ORACLE_HOME=/usr/lib/oracle/11.2/client64
    

    MacOS users will need:

    DYLD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/
    

    Also add ORACLE_HOME to your PATH variable.

  • download DBD::Oracle from CPAN

  • untar the module and run below commands in given sequence:

    perl Makefile.PL
    make
    sudo make install
    

In case you get complaints about missing gcc you can (temporarily) install it and then remove it.

DONE !!!

Issues I had faced were due to the wrong LD_LIBRARY_PATH. I had set it to /usr/lib/oracle/11.2/client64 whereas the correct value is /usr/lib/oracle/11.2/client64/lib.

Certainly, this was a great learning for a newbie like me.

1
6

you can also read my article How to install DBD::Oracle which contains all the steps required to install DBD::Oracle CPAN module, which is not a straightforward installation. The purpose is to reduce headache and turn it into a repeatable process.

5
  • @gerardw: thanks for report it, I just removed the last slash, maybe it happened since GitHub Pages upgraded to Jekyll3 and link format changes. Actually I do not pretend to hype that link and I do not gain money with my web site, I like to share my knowledge to give back to the community, and I am really convinced that the article can help other people that struggled (like me :) trying to install DBD::Oracle. Feb 7, 2016 at 20:36
  • Any chance you can update that doc for 12.x? 12.2 at least doen't include a .mk file, and the "demo" one is something that the build complains about. Why cant the CPAN module work for anything more recent than from 2014?
    – Otheus
    Jul 19, 2017 at 18:11
  • Hi @Otheus I am sorry but I am not using Oracle recently so I don't have an Oracle 12 to test it. Article was written for Oracle 11g, but, I don't understand the .mk file that you are referring since there is no mention in the article instructions. At which article's instruction step did you arrived? Which error did you get? Maybe I can help as well. Jul 24, 2017 at 22:17
  • YEs, the instructions are short on helpful information. There is a .mk file which Oracle uses to help API compilers link in and get all the right headers. Unfortunately, they keep moving that file around in different directory structures. The latest is listed as demo.mk. Very (not so) obvious. :( To get the DBD module to work, I needed only to cp the files in the directory containing demo.mk to its parent directory.
    – Otheus
    Jul 27, 2017 at 18:24
  • Prolly the best options is to report it here github.com/pythian/DBD-Oracle/issues Jul 29, 2017 at 17:53
4

Here's what I did on CentOS 7.2 using yum packages and CPAN. This assumes you're using Oracle version 12.1 but I would imagine most versions will work this way.

Install Oracle Instant Client

yum install oracle-instantclient12.1-basic-12.1.0.2.0-1 oracle-instantclient12.1-devel-12.1.0.2.0-1 oracle-instantclient12.1-sqlplus-12.1.0.2.0-1

Copy demo make files

The install expects the *.mk file to be in /usr/share/oracle/12.1/client64 but the yum package install puts them in /usr/share/oracle/12.1/client64/demo.

sudo cp /usr/share/oracle/12.1/client64/demo/* /usr/share/oracle/12.1/client64

Modify .bashrc

Add the following lines to your ~/.bashrc

export ORACLE_HOME=/usr/lib/oracle/12.1/client64
export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib
export PATH=$ORACLE_HOME:$PATH

Now source the file

source ~/.bashrc

Update CPAN and DBI

Update CPAN and DBI to the latest

cpan> install CPAN
cpan> reload cpan
cpan> install DBI

Install DBD::Oracle

cpan> install DBD::Oracle
1
  • Works for 12.2 64bit but there are warnings/errors. (Size_t conflicts with %d format, mainly.) Many thanks
    – Otheus
    Jul 19, 2017 at 18:15
0

A little addition to slayedbylucifer answer. I had the same problem like mentioned in the question. I've done all the steps described by slayedbylucifer. But still I got the problem like mentioned here:

/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /opt/oracle/app/oracle/product/11.2.0/client_1/lib//libclntsh.so when searching for -lclntsh
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: cannot find -lclntsh

So I created the following symbolic link:

ln -s /opt/oracle/app/oracle/product/<YOUR_ORACLE_VERSION>/client_1/lib/libclntsh.so $ORACLE_HOME/libclntsh.so*

After that step the error from above (cannot find -lclntsh) was fixed. The execution of the make command was without any errors.

The only problem I still have is that I don't understand why this symbolic link is necessary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.