Install Perl module DBD::Oracle on Intel macs.

Nov 02, '06 07:30:00AM

Contributed by: atverd

Oracle has an "instant client" for Mac OS X and it's available for free from their site. Unfortunately it's PowerPC only and nobody knows when they going to release an Intel or Universal version. It works through Rosetta though and if you just install the client as they say, you may use sqlplus and other PowerPC applications linked with that client this way.

The problem for me was that I couldn't use those libraries with Perl: DBD::Oracle just wouldn't build properly, because by default gcc builds everything for Intel only, and this code cannot be linked with PowerPC libraries. So the idea is simple: run Perl through Rosetta when you have to deal with Oracle and everything should be fine.

Here are step-by-step instructions showing how I made it work. I assume that the Oracle instant client is already installed and works; I used version 10.1.0.3. Also, make a backup. Nothing special happens here, but you never know.

1. We need to create a PowerPC-only Perl binary. To do this type this command in Terminal:

sudo lipo -thin ppc -output /usr/bin/perl.ppc /usr/bin/perl 
Perl in Mac OS X 10.4 is universal and the command simply copies it's PowerPC part to file perl.ppc. The original perl binary is still universal and is not changed in any way.

2. We need universal DBI (DBD::Oracle is just a driver for DBI). Download the latest DBI (version 1.52 at the moment), extract it and go to the DBI-1.52 directory. Here you need to create a directory named "hints" and create the file darwin.pl with this content:
#!/usr/bin/perl

$arch = "-arch i386 -arch ppc";
print "Adding $archn";

$self->{CCFLAGS} = "$arch $Config{ccflags}";
$self->{LDFLAGS} = "$arch $Config{ldflags}";
$self->{LDDLFLAGS} = "$arch $Config{lddlflags}";

3. Do regular:
perl Makefile.PL
make
make test
sudo make install
"make test" will test the Intel instance of the DBI, but if you use perl.ppc in the first line instead of perl it will run all tests through Rosetta through PowerPC instance of the DBI.

Now we have the universal DBI installed.

4. Download DBD::Oracle. I used version 1.18a. Again extract it, go to the newly created DBD-Oracle-1.18, create a directory named "hints", and put there darwin.pl with slightly different content:

#!/usr/bin/perl

$arch = "-arch ppc";
print "Adding $archn";

$self->{CCFLAGS} = "$arch $Config{ccflags}";
$self->{LDFLAGS} = "$arch $Config{ldflags}";
$self->{LDDLFLAGS} = "$arch $Config{lddlflags}";
5. Again, but with the perl.ppc we created before:

perl.ppc Makefile.PL
make
make test
sudo make install
"make test" may or may not work depending on your setup: check the documentation for DBD::Oracle for details.

That's it - now we have everything installed and your old scripts should just work if instead of regular /usr/bin/perl you use /usr/bin/perl.ppc. DBI is universal and should work for Intel and PowerPC. The only problem is that Perl in Rosetta works a lot slower, but I guess this is better than nothing.

[kirkmc adds: I haven't tested this...]

Comments (10)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20061021211559813