Strawberry Perl + DBD::Oracle for MS Windows...

While helping a developer at my company get up and running with some DBI/DBD stuff I came across the Open Source Strawberry Perl distribution for Windows. It is an all-in-one package of Perl interpreter and many common packages required to get productive. Hopefully gone are the days of struggling to find a DBD driver compiled for Windows... From the website:

Strawberry Perl is a perl environment for MS Windows containing all you need to run and develop perl applications. It is designed to be as close as possible to perl environment on UNIX systems.
It includes perl binaries, compiler (gcc) + related tools, all the external libraries (crypto, graphics, xml ...), all the bundled database clients and all you expect from Strawberry Perl.

They offer 32/64 bit distribution packages in multiple forms including a tidy .MSI installer if you have admin privileges or a self contained ZIP edition that does not require admin privileges - just drop it in a directory and go.

They also offer a set of files that you can use to build your own custom Strawberry Perl install packages - probably good if you are developing a packaged application.

You can load up on this tasty perl goodness at the http://StrawberryPerl.com website. Instructions for installing DBD::Oracle are here

I had to go through a little pain to get DBD::Oracle installed, but considering Strawberry includes all the gcc and make tools required this is much easier than starting from scratch... The main issue was a part in the Makefile.pl that tries to run SQLPLUS to get the version. For some reason backticks wasn't cooperating on my machine, but the Makefile has a command line option to force the version. To do this I had to run a bunch of the make steps manually but its all good, here is what I did to get it to work:

1) Download and extract Strawberry Perl ZIP Edition to c:\perl
2) Download and extract oracle instant client files to c:\perl\instantclient_11_2. I downloaded the Win32 InstantClient, the SQLPlus, and the SDK packages from the Instant Client Download Page
3) Create c:\perl\instantclient_11_2\network\admin, copy tnsnames.ora, ldap.ora, sqlnet.ora there
4) Install Oracle::DBD, open a cmd.exe window and:

c:
cd \perl

relocation.pl.bat
update_env.pl.bat

After this step you must exist your cmd.exe window and start it again for the Perl related environment variables to take effect.

c:
cd \perl

REM At this point c:\perl\perl\bin should be available, this should result in a version banner: 
perl -v

SET ORACLE_HOME=c:\perl\instantclient_11_2
SET LD_LIBRARY_PATH=c:\perl\instantclient_11_2
SET TNS_ADMIN=c:\perl\instantclient_11_2\network\admin
SET NLS_LANG=American_America.UTF8

SET PATH=%PATH%;c:\perl\instantclient_11_2

REM A more isolated version of a PATH I used for testing when I had multiple clients installed: 
REM SET PATH=C:\perl\perl\site\bin;C:\perl\perl\bin;;C:\perl\c\bin;C:\perl\perl\site\bin;C:\perl\perl\bin;c:\perl\instantclient_11_2;


REM Run CPAN and execute some cpan commands:
CPAN

get DBD::Oracle
look DBD::Oracle

perl Makefile.pl -V 11.2
dmake
dmake test
dmake install
exit
exit

REM Using the test script below, make sure you can invoke DBI and talk to an Oracle database
perl test.pl scott tiger orcl out.txt

Once you are done and run a test script (like this one here) to test connectivity you should be good to go. Make sure you permanently set the SET parameters above permanently in your environment. You can either incorporate them into a batch file before every program run or set them permanently in Windows via the Manage -> Environment Variables screen.

Comments

Try installing it on a 64 bit Windows machine and it still gives all those errors

Thanks for the update, I will give it a shot when I get a chance to try on a 64-bit machine. What were the most prominent errors you saw? Curious if the issue was more with the Oracle Client or the Perl install.

I got it to build with 5.16.2 x64. I added my notes as comments to the Pythian article:
http://www.pythian.com/news/11115/dbdoracle-and-windows-64bit

Thanks for the followup Lyle. I am in the process of setting up a new Win7 64-bit on VirtualBox so I can see how far I can get with Strawberry Perl's built in GCC again, will report back soon.

Add new comment