bluethundr has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks,

I've been struggling for about a week with getting perl to work with Oracle database.

Finally I was able to get both the DBI and Oracle DBD CPAN modules I had downloaded installed successfully when I dug through the links someone posted on perlmonks regarding compiling cpan modules under Solaris.

This advice was the most useful:

Building CPAN modules on Solaris might be a bit different than on your + average Linux platform. Here is the reason why: Solaris 10 comes pre-installed with Perl 5.8.4. This is the good news. + However, it has been built with Sun's Studio compiler suite. When pe +rl is built it saves the name of the compiler and any compiler flags +in its configuration files, and then uses these saved settings when a +ny additional modules are built. So when you try to build additional +modules it will expect to find the Sun Studio compiler. Solaris 10 comes pre-installed with GNU C/C++ compiler but the Sun Stu +dio compiler is optional and is likely not installed. Luckily Solaris comes with a tool called perlgcc that fixes this probl +em. It will make sure that modules are build with gcc rather than the + Sun Studio compiler. Instead of invoking perl Makefile.PL to generat +e the makefile needed to compile a module, perlgcc Makefile.PL should + be used instead. All command-line arguments to perlgcc are passed un +modified to perl. Needless to say you can forget all in this article if you have Sun Stu +dio compiler installed and wish to use that for building modules. How +ever most Perl modules have only been tested to compile with the GNU +C/C++ compiler so if you do not want trouble stick with the recipe in + this article.


I was able to find this useful info here:
Building CPAN Perl modules on Solaris 10 (and 11)

It turned out that I needed a command called perlgcc to compile the CPAN module and not the perl command.

So, instead of
perl Makefile.PL
I needed to use
perlgcc Makefile.PL
Instead. Once I did that everything went smoothly and installed no problem.

However, when I run my dbi test script I am seeing an error:
[db07-dc2:~] root% ./dbitest.pl ld.so.1: perl: fatal: relocation error: file /usr/perl5/site_perl/5.8. +4/sun4-solaris-64int/auto/DBD/Oracle/Oracle.so: symbol OCINlsEnvironm +entVariableGet: referenced symbol not found Killed


This is the script I am trying to run
#!/usr/bin/perl use warnings; use strict; use DBI; my $ORACLE_HOME = "/u01/app/oracle/product/10.2.0.4"; my $ORACLE_SID="qaecom2"; my $USER="user"; my $PASS="password"; $ENV{ORACLE_HOME}=$ORACLE_HOME; $ENV{ORACLE_SID}=$ORACLE_SID; $ENV{PATH}="$ORACLE_HOME/bin"; $ENV{LD_LIBRARY_PATH}="$ORACLE_HOME/lib"; use strict; use DBI; my $dbh = DBI->connect( "dbi:Oracle:$ORACLE_SID", "$USER", "$PASS", ) || die "Database connection not made: $DBI::er +rstr"; $dbh->disconnect;
Here's my machine info and perl version

[db07-dc2:~] root% uname -a SunOS db07-dc2 5.10 Generic_147440-09 sun4u sparc SUNW,Sun-Fire-15000


[db07-dc2:~] root% perl -v This is perl, v5.8.4 built for sun4-solaris-64int (with 36 registered patches, see perl -V for more detail)
I was hoping that someone out there might have enough experience with this type of error to suggest a solution. Thanks in advance!

Replies are listed 'Best First'.
Re: perl: fatal: relocation error:
by Anonymous Monk on Jun 04, 2012 at 01:43 UTC

    :) I think I understand the error message , site:perlmonks.org solaris relocation error, either you're mixing 32-bit/64-bit binaries (perl and oracle), or you're running a different perl than the one you compiled the module with, or you didn't set all required oracle vars, or LD_LIBRARY_PATH is missing oracle paths

    :) also perlgcc doesn't appear to have been updated in a decade -- I hear installing a new perl ( say in /usr/local/opt or some such) is easier to work with

    :) Is that Solaris 10? I hear that one is unsupported ... :P

Re: perl: fatal: relocation error:
by NetWallah (Canon) on Jun 04, 2012 at 00:56 UTC
    I'm not sure I understand what this php archive message is saying.

    It seems like you may have to set the environment $ORACLE_HOME before you build the oracle DBD module.

                 I hope life isn't a big joke, because I don't get it.
                       -SNL

      Build and run http://search.cpan.org/dist/DBD-Oracle/README

      Oracle Environment Variables To use DBD::ORACLE to connect to an Oracle database, ORACLE_HOME environment variable should be set correctly. In general, the valu +e used should match the version of Oracle that was used to build DBD::Ora +cle. If using dynamic linking then ORACLE_HOME should match the version + of Oracle that will be used to load in the Oracle client libraries (v +ia LD_LIBRARY_PATH, ldconfig, or similar on Unix).