Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Install Perl module DBD::Oracle on Intel macs. System 10.4
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 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 with this content:

$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 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 with slightly different content:


$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 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...]
  • Currently 2.33 / 5
  You rated: 5 / 5 (6 votes cast)

Install Perl module DBD::Oracle on Intel macs. | 10 comments | Create New Account
Click here to return to the 'Install Perl module DBD::Oracle on Intel macs.' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Can we get an "Intel Only" category? (N/T)
Authored by: dzurn on Nov 02, '06 10:48:23AM

Can we get an "Intel Only" category? This isn't really a System 10.4 hint, but rather an Intel hint. Should add that tag to MacOSXHints.

Madness takes its toll.
Please have exact change.

[ Reply to This | # ]
Install Perl module DBD::Oracle on Intel macs.
Authored by: pgammer on Apr 12, '07 01:48:01AM

You are a legend !
An excellent recipe that does exactly as it claims.
Worked a treat on my MBP.
Thank you very much.

[ Reply to This | # ]
Install Perl module DBD::Oracle on Intel macs.
Authored by: chs76945 on Oct 04, '07 09:33:07AM
This is a great article, and it helped me immensely. FINALLY, I can store and develop my Oracle-backended perl applications on my laptop instead of remotely on a Unix system.

A note that might help many: the 10.1 version of instanctclient was built incorrectly, and has a hardcoded link to a library on some developer's workstation somewhere out in Oracle land. (Don't ask me how their QA missed this.)

If, when loading DBD::Oracle, you get some noise like "dyld: Library not loaded: /b/729/rdbms/lib/libclntsh.dylib.10.1", it just means that the Oracle bundle wants it's buddy /b/729/rdbms/lib/libclntsh.dylib.10.1 and can't find it. A simple (but not particularly elegant) workaround is to just give it what it wants by putting a symlink to that library in that location.

The following commands should do it (execute in the terminal). You must replace INSTALLDIR with the path to wherever you installed the instantclient; if you're really not sure, simply navigate to the instant client directory in the finder and just drop libclntsh.dylib.10.1 into the terminal window when you get to that part of the command (in which case you don't need to type the filename part either).

sudo mkdir -p /b/729/rdbms/lib/
sudo ln -s INSTALLDIR/libclntsh.dylib.10.1 /b/729/rdbms/lib/

[ Reply to This | # ]

Install Perl module DBD::Oracle on Intel macs.
Authored by: paco on Jan 31, '08 10:19:44AM

The alternative that I found is to use the DYLD_LIBRARY_PATH (MacOS equivalent of LD_LIBRARY_PATH on other unixes).

I have my instantclient installed in /opt/local/oracle, so I do the following in my environment (e.g., .profile):

export DYLD_LIBRARY_PATH=/opt/local/oracle

No need to create the path.

[ Reply to This | # ]
Install Perl module DBD::Oracle on Intel macs.
Authored by: fabs on Nov 02, '07 08:03:56AM
In Leopard the first step won't work because the Perl binary only contains the Intel code. When you install ActivePerl 5.8.x, which is a Universal binary, you can replace the first step by

sudo lipo -thin ppc -output /usr/local/ActivePerl-5.8/bin/perl.ppc /usr/local/ActivePerl-5.8/bin/perl

and all remaining steps are exactly the same after you append /usr/local/ActivePerl-5.8/bin to $PATH!

[ Reply to This | # ]

Install Perl module DBD::Oracle on Intel macs.
Authored by: atverd on Nov 05, '07 03:32:17PM

/usr/bin/perl is still universal, but the architecture name is changed now. It should be

sudo lipo -thin ppc7400 -output /usr/bin/perl.ppc /usr/bin/perl

[ Reply to This | # ]
Extra Instructions for v1.20 and Leopard
Authored by: paco on Jan 31, '08 11:46:30AM

I tried this on DBD::Oracle v 1.20 and Leopard. I had to use the hint that someone else gave about using the -ppc7400 argument to lipo.

Even after that, I got it to compile correctly, but it wouldn't run. I got this error:

Can't load '/Library/Perl/5.8.8/darwin-thread-multi-2level/auto/DBD/Oracle/Oracle.bundle'
 for module DBD::Oracle:
dlopen(/Library/Perl/5.8.8/darwin-thread-multi-2level/auto/DBD/Oracle/Oracle.bundle, 1):
Symbol not found: _environ
  Referenced from: /Library/Perl/5.8.8/darwin-thread-multi-2level/auto/DBD/Oracle/Oracle.bundle
  Expected in: dynamic lookup
 at ./ line 4

It turns out there's a function called dump_env_to_trace() that's not very important. It's only called in a few instances for debugging purposes. Rather than fix it, I just took it out and removed all references to it.

If you know how to use patch, here's a patch file. Save this as dbdimp.diff

--- dbdimp.c.orig	2007-12-21 11:03:55.000000000 -0500
+++ dbdimp.c	2008-01-31 14:19:37.000000000 -0500
@@ -56,7 +56,6 @@
 static sql_fbh_t ora2sql_type _((imp_fbh_t* fbh));
 void ora_free_phs_contents _((phs_t *phs));
-static void dump_env_to_trace();
 static sb4
 oci_error_get(OCIError *errhp, sword status, char *what, SV *errstr, int debug)
@@ -383,9 +382,6 @@
     imp_dbh->get_oci_handle = oci_db_handle;
-    if (DBIS->debug >= 6 )
-	dump_env_to_trace();
     if ((svp=DBD_ATTRIB_GET_SVP(attr, "ora_envhp", 9)) && SvOK(*svp)) {
 	if (!SvTRUE(*svp)) {
 	    imp_dbh->envhp = NULL; /* force new environment */
@@ -3503,20 +3499,3 @@
     return sql_fbh;
-static void
-dump_env_to_trace() {
-	dTHX;
-    PerlIO *fp = DBILOGFP;
-    int i = 0;
-    char *p;
-#ifndef __BORLANDC__
-    extern char **environ;
-    PerlIO_printf(fp, "Environment variables:\n");
-    do {
-	p = (char*)environ[i++];
-	PerlIO_printf(fp,"\t%s\n",p);
-    } while ((char*)environ[i] != '\0');

If you're not familiar with how patch works, just save that diff file in the same directory as dbdimp.c. Then run patch < dbdimp.dif. It will find the file and patch it.

Now go make as usual.

I'll notify the DBD::Oracle guys about this as well.

[ Reply to This | # ]
Install Perl module DBD::Oracle on Intel macs.
Authored by: atverd on Apr 24, '08 01:53:20PM
Oracle finally released instant client for Intel:

You still need _environ patch to DBD::Oracle though.

[ Reply to This | # ]
Install Perl module DBD::Oracle on Intel macs.
Authored by: atverd on Apr 24, '08 02:11:23PM
The patch for _environ problem

--- dbdimp.c.orig	2008-04-03 11:07:56.000000000 -0700
+++ dbdimp.c	2008-04-24 13:57:06.000000000 -0700
@@ -17,6 +17,10 @@
 #include "w32api/winbase.h"
 #endif /* __CYGWIN32__ */
+#ifdef __APPLE__
+#include <crt_externs.h>
 #include "Oracle.h"
 #if defined(CAN_USE_PRO_C)
@@ -3793,9 +3797,13 @@
     PerlIO *fp = DBILOGFP;
     int i = 0;
     char *p;
+#ifdef __APPLE__
+    #define environ (*_NSGetEnviron())
 #ifndef __BORLANDC__
     extern char **environ;
     PerlIO_printf(fp, "Environment variables:\n");
     do {
 	p = (char*)environ[i++];

[ Reply to This | # ]
Install Perl module DBD::Oracle on Intel macs.
Authored by: boingolover on Jan 25, '09 07:06:05AM

The _environ bug has been closed finally, a patch has been rolled in with the trunk and hopefully should be out with the next release of DBD::Oracle (1.23?) I created a patch for it based on the information I found in this thread. You can download the patch against 1.22 here: (dbdimp.diff)

or on my blog, which I include a writeup on how to get this going on intel mac (some of it based on this thread).

[ Reply to This | # ]