DBD::Oracle with gcc and Oracle Instant Client on AIX

DBD::Oracle with gcc and Oracle Instant Client on AIX

am 16.12.2005 02:28:26 von nathan.vonnahme

Yes! It eluded me last year but I finally got DBD::Oracle working on an
AIX machine using gcc. Here's the short version:

First I had to recompile perl with gcc, using
sh Configure -de -Dcc=3Dgcc
This apparently built a 32 bit perl, someday I will try getting it to go
64 bit.

I was then able to install and build DBI 1.50 with the CPAN shell.

I downloaded the base and sdk packages of the Oracle Instant Client for
AIX -- first I tried the 64 bit but that didn't work with my 32 bit perl
-- the 32 bit version (still at 10.1.0.3) did the trick. I unzipped
them and moved the dir to /usr/local/oracle/instantclient10_1 and made a
symlink without the version at /usr/local/oracle/instantclient , then
set:

export ORACLE_HOME=3D/usr/local/oracle/instantclient
export LIBPATH=3D$ORACLE_HOME

Using the pythian subversion branch of DBD::Oracle, I modified the
Makefile.PL to find the right files, because Oracle Instant Client for
AIX is a bit different than Linux. (I also made some other cosmetic
changes, see the diff below, plus my yesterday changes for Linux-- I
could commit them if someone gives me credentials?)

Oracle wasn't providing the sqlplus package for 32 bit AIX so I
explicitly told Makefile.PL the version:

perl Makefile.PL -V 10.1

It appears to work so far, and I tested it again on the Linux machine I
dealt with yesterday. But I haven't got the entire test suite passing
because I don't have a database instance to connect to with scott/tiger.
I hacked t/10general.t to connect to a database on another machine and
it passed. If I get time I'll change all the .t files to accept a DBI
connect string from the environment so you could connect to another
machine by setting e.g. ORACLE_DBI_STR=3DDBI:Oracle://server/instance --
wouldn't that be good for client-only installs?

-n




Index: Makefile.PL
==================== =====3D=
==================== =====3D=
=================3D
--- Makefile.PL (revision 2309)
+++ Makefile.PL (working copy)
@@ -18,6 +18,16 @@
## Changes made
## Adding in a few changes suggested by Andy Hassall

## that will enable the compile to work for Windows version of the IC
+##
+## Nathan.Vonnahme at banner health dot com
+## Dec 14 2005
+## tweak to find Oracle Instant Client 10.2.0.1 on Linux when
installed via Oracle's RPMs,
+## which scatter the instant client files into /usr/lib/oracle,
/usr/include/oracle, and
+## /usr/share/oracle
+##
+## Dec 15 2005
+## tweak to find Oracle Instant Client on AIX
+## coupla readability improvement

# vim: ts=3D8:sw=3D4

@@ -154,16 +164,22 @@

print "os=3D$os\n";

+# These files indicate the presence of the Oracle Instant Client
+my $instantclient =3D
+ -e "$OH/libclntsh.so.10.1" || # Linux and some? Unixes
+ -e "$OH/libclntsh.a" || # AIX
+ -e "$OH/oci.dll" || # Windows
+ 0
+;
+print "Using Oracle Instant Client in $OH\n" if $instantclient;
+
die qq{ The $ORACLE_ENV environment variable value ($OH) is not valid.
It must be set to hold the path to an Oracle installation directory
on this machine (or a machine with a compatible architecture)
See the README.clients file for more information.
ABORTED!
-} unless (($os eq 'VMS') ? -d $OH : (-e "$OH/libclntsh.so.10.1" || -e
"$OH/oci.dll") ? 1 : -d "$OH/lib/.");
-
+} unless (($os eq 'VMS') ? -d $OH : $instantclient ? 1 : -d
"$OH/lib/.");

-#the (-e "$OH/libclntsh.so.10.1" ) supports the 10g Instant Client on
UNIX and Linux
-#The -e "$OH/oci.dll" supports the 10g Instant Client on Windows.

die qq{ The $ORACLE_ENV environment variable value ($OH) is not valid.
It must be set to hold the path to an Oracle installation directory
@@ -358,30 +374,31 @@

# --- special case for Oracle 10g instant client

-elsif (-e "$OH/libclntsh.so.10.1") { # note lack of ../lib/...
+elsif ($instantclient) {

- #support for 10 instantclient
- # John Scoles
- # --- the simple modern way ---
-
- eval { symlink("$OH/libclntsh.so.10.1","$OH/libclntsh.so") };
- # need to link so.10.1 file to .so
+ if ( -e "$OH/libclntsh.so.10.1" && ! -e "$OH/libclntsh.so" ) {
+ # need to link so.10.1 file to .so
+ eval { symlink("$OH/libclntsh.so.10.1","$OH/libclntsh.so") };
+ }
+
# hard coded the link dir here and below

print "Found direct-link candidate: clntsh\n";
+ # this will work for libclntsh.a or libclntsh.so (the new symlink
we just made)
my $lib =3D "clntsh";
my $syslibs =3D read_sysliblist();

print "Oracle sysliblist: $syslibs\n";

# no library dir with instantclient
- my $libdir =3D "";
+ #my $libdir =3D "";

$opts{dynamic_lib} =3D { OTHERLDFLAGS =3D> "$::opt_g" };

$linkwith_msg =3D "-l$lib.";
- $opts{LIBS} =3D [ "-L$OH/$libdir -l$lib $syslibs"];
+ $opts{LIBS} =3D [ "-L$OH -l$lib $syslibs"];
my $inc =3D "-I$OH\/sdk/include";
+ $inc .=3D " -I/usr/include/oracle/$client_version_full/client"; #
where Oracle's rpms put the .h files
$opts{INC} =3D "$inc -I$dbi_arch_dir";

}
@@ -776,8 +793,9 @@

if ($os eq 'aix' and $osvers >=3D 4 and $Config{cc} ne 'xlc_r') {
print "\n\n";
- print "Warning: You will may need to rebuild perl using the xlc_r
compiler.$BELL\n";
- print " You may also need do: ORACCENV=3D'cc=3Dxlc_r'; =
export
ORACCENV\n";
+ print "Warning: You may need to rebuild perl using the xlc_r
compiler.$BELL\n";
+ print " The important thing is that perl and DBD::Oracle be
built with\n";
+ print " the same compiler. You may need:
ORACCENV=3D'cc=3Dxlc_r'; export ORACCENV\n";
print " Also see the README about the -p option\n";
sleep 5;
}


--
nathan vonnahme, system engineer at fairbanks memorial hospital
1650 cowles street, fairbanks alaska 99701. 907-458-5464