How to Set Up 64-bit Perl on AIX 5.2
— ny_wk

Setting up 64-bit Perl on AIX 5.2 so that the DB2 Perl driver (DBD::DB2) can connect to a DB2 database comes down to two reliable paths: use IBM's pre-packaged 64-bit Perl that ships with AIX, or compile your own 64-bit Perl from source. Both then layer the DBI and DBD::DB2 CPAN modules on top. This guide walks through each route end to end, fixes the gotchas that silently break the build, and shows you how to verify the result.
A note before you start: AIX 5.2 reached end of support in 2009, and DB2 versions from that era are long out of service. If you are building a new system, run a current AIX (7.2/7.3) with a modern Perl and the maintained DBD::DB2 from CPAN against a supported Db2 release. The procedure below is for the real-world case of maintaining, migrating off, or auditing an existing legacy AIX 5.2 box where the original toolchain must be reproduced exactly.
The problem: why 64-bit Perl matters for DB2 on AIX 5.2
The DB2 client libraries on a 64-bit AIX instance are 64-bit. A Perl interpreter built in 32-bit mode cannot link against 64-bit DB2 shared objects, so when you try to make the DBD::DB2 driver you get cryptic linker errors about wrong-class objects (XCOFF32 vs XCOFF64). The fix is to ensure Perl itself is 64-bit before you build DBI and DBD::DB2 against it. Everything that follows exists to guarantee that single condition: the perl in your PATH is a 64-bit binary that links cleanly against your DB2 sqllib.
Prerequisites and a quick environment check
- Root access for installing the eFix and relinking
/usr/bin/perl. - A working C compiler (IBM XL C/C++, e.g.
xlc/cc, or a compatible GCC) — DBI and DBD::DB2 contain XS (C) code that must be compiled. - An installed DB2 client or server with a populated
sqllibdirectory (the driver links against headers and libraries there). - The GNU make or AIX
makeavailable, plusgzipandtar.
Confirm which Perl is currently active and whether it is 64-bit:
- Find the interpreter that will be used:
which perl - Inspect its build configuration:
perl -V
In the output of perl -V, look for the line use64bitall=define. If you instead see use64bitall=undef (or usemymalloc/pointer sizes that imply 32-bit), the active Perl is 32-bit and DBD::DB2 will not link. The perl -V output also tells you which compiler built that Perl, which you will want to match when compiling the XS modules.
Option 1: Use the pre-packaged 64-bit Perl (recommended)
AIX 5.2 ships a 64-bit Perl 5.8.0 under /usr/opt/perl5. Switching the system perl over to it is the fastest and most supportable route because IBM built and tested that binary for the platform.
Step 1.1 - Apply the perlconfig eFix
The stock AIX 5.2 Perl shipped with a truncated Config.pm, and an interim fix (eFix) named perlconfig repairs it. Without it, module builds that read Perl's configuration can fail in confusing ways. Check whether the eFix is installed (as root):
- List installed eFixes and filter for Perl:
emgr -l | grep -i perl
If the eFix is present you will see a line whose abstract reads "fixes truncated Config.pm for Perl", for example:
| ID | STATE | LABEL | ABSTRACT |
| 1 | S | perlconfig | fixes truncated Config.pm for Perl |
The S state means the fix is in the STABLE (installed and committed-style) state. If you do not see that abstract, the eFix is missing. Obtain the package perlconfig.083004.epkg.Z from your AIX support channel, then install it as root:
- Install the eFix:
emgr -e perlconfig.083004.epkg.Z - Re-verify:
emgr -l | grep -i perl
See man emgr for preview (-p), removal (-r), and commit options. The -e flag installs an emergency-fix package; the .Z extension means it is compressed and emgr handles the decompression for you.
Step 1.2 - Switch /usr/bin/perl to the 64-bit interpreter
The file /usr/opt/perl5/README documents the supported way to make the pre-packaged 64-bit Perl the system default. Read that README first in case paths changed for your maintenance level, then run a short ksh script as root that relinks the public Perl entry points to their _64bit counterparts:
- Open a root shell and create the script (for example
switch_perl64.ksh):
#!/bin/ksh
ln -f /usr/opt/perl5/bin/perl5.8.0_64bit /usr/bin/perl
ln -sf /usr/opt/perl5/bin/a2p_64bit /usr/bin/a2p
ln -sf /usr/opt/perl5/bin/cppstdin_64bit /usr/bin/cppstdin
ln -sf /usr/opt/perl5/bin/enc2xs_64bit /usr/bin/enc2xs
ln -sf /usr/opt/perl5/bin/h2ph_64bit /usr/bin/h2ph
ln -sf /usr/opt/perl5/bin/libnetcfg_64bit /usr/bin/libnetcfg
ln -sf /usr/opt/perl5/bin/perlbug_64bit /usr/bin/perlbug
ln -sf /usr/opt/perl5/bin/perlcc_64bit /usr/bin/perlcc
ln -sf /usr/opt/perl5/bin/perldoc_64bit /usr/bin/perldoc
ln -sf /usr/opt/perl5/bin/perlivp_64bit /usr/bin/perlivp
ln -sf /usr/opt/perl5/bin/splain_64bit /usr/bin/splain
Note the first line uses ln -f (a hard link) for the main perl binary, while the helper scripts use ln -sf (a symbolic link). Make it executable and run it:
- Make it runnable:
chmod +x switch_perl64.ksh - Run it as root:
./switch_perl64.ksh - Confirm the switch:
perl -V | grep use64bitallshould showuse64bitall=define.
Also verify your compiler is intact, because the next steps compile C code. The perl -V output shows the cc= and ccflags= values used to build this Perl; make sure that compiler exists and is in your PATH.
Step 1.3 - Install the DBI module from CPAN
DBI is the database-independent interface layer that DBD::DB2 plugs into. Make sure the 64-bit Perl is the one in your path (which perl must return the interpreter you just linked), then download the latest DBI from CPAN. The original procedure referenced DBI-1.43; use whatever current DBI release is compatible with Perl 5.8 if you are reproducing this exactly. Unpack and build it:
- Decompress:
gzip -d DBI-1.43.tar.gz - Extract:
tar -xf DBI-1.43.tar - Enter the directory:
cd DBI-1.43 - Generate the Makefile:
perl Makefile.PL - Compile:
make - Run the test suite:
make test - Install (as root, or use
sudo):make install
Do not skip make test. If the tests fail here, DBD::DB2 will not work either, and it is far easier to diagnose a DBI problem in isolation than buried under a driver build.
Step 1.4 - Install the DBD::DB2 driver
DBD::DB2 is IBM's driver that lets DBI talk to DB2. Download the current driver source from IBM's DB2 Perl page. The original procedure used DBD-DB2-0.78. The single most common failure here is the build not knowing where DB2 lives.
If you are building as root or any user that is not your DB2 instance owner, you must point the build at the DB2 sqllib directory by exporting DB2_HOME first. For an instance at /home/db2inst1/sqllib:
- Set the DB2 home:
export DB2_HOME=/home/db2inst1/sqllib - Decompress:
gzip -d DBD-DB2-0.78.tar.gz - Extract:
tar -xf DBD-DB2-0.78.tar - Enter the directory:
cd DBD-DB2-0.78 - Read the README — it lists exact system and version requirements.
- Generate the Makefile:
perl Makefile.PL - Compile:
make - Test:
make test - Install:
make install
The make test step for DBD::DB2 typically needs a reachable test database and valid credentials; consult the README for how to point the tests at an instance, or be prepared to validate connectivity manually after install.
Option 2: Build 64-bit Perl from source on AIX 5.2
If the pre-packaged Perl is unavailable, the wrong version, or you need a specific Perl release, compile your own. This gives you full control over where Perl installs and which features are enabled. The example uses Perl 5.8.4.
Step 2.1 - Download, configure, and compile
Fetch the latest stable Perl tarball from the official Perl site. After download, give it a clear name and unpack it:
- Rename for clarity (example): the downloaded
stable.tar.gzbecomesperl584.tar.gz. - Decompress:
gzip -d perl584.tar.gz - Extract:
tar -xf perl584.tar - Enter the source directory:
cd perl-5.8.4 - Configure for full 64-bit:
./Configure -Duse64bitall
The flag -Duse64bitall is the critical one: it tells Perl to build a fully 64-bit interpreter (64-bit integers, pointers, and the use of 64-bit system libraries), which is required to link against 64-bit DB2. The weaker -Duse64bitint only widens integers and is not sufficient here. Configure prompts for the install location; accept the defaults (which may overwrite an existing Perl) or specify a fresh prefix to keep the two side by side. Installing into a shared filesystem such as AFS lets multiple hosts share one build.
When configuration finishes, build and install:
- Compile:
make - Run the regression tests:
make test - Install:
make install
Verify the result is genuinely 64-bit:
- Check the build flags:
perl -V | grep use64bitall
You must see use64bitall=define. Then confirm this is the Perl on your path with which perl; if not, prepend its bin directory to PATH (for example export PATH=/usr/local/bin:$PATH) before building any modules.
Step 2.2 - Install DBI against your custom Perl
The procedure is identical to Step 1.3, except DBI is now built against your freshly compiled interpreter. With the correct perl first in PATH:
gzip -d DBI-1.43.tar.gztar -xf DBI-1.43.tarcd DBI-1.43perl Makefile.PLmakemake testmake install
Step 2.3 - Install DBD::DB2 against your custom Perl
Same as Step 1.4 — and the DB2_HOME rule still applies if you are not the instance owner:
export DB2_HOME=/home/db2inst1/sqllib(adjust to your instance)gzip -d DBD-DB2-0.78.tar.gztar -xf DBD-DB2-0.78.tarcd DBD-DB2-0.78perl Makefile.PLmakemake testmake install
Common pitfalls when building 64-bit Perl and DB2 on AIX
- Wrong Perl in PATH. The number-one cause of failed driver builds:
makeruns against a 32-bitperlstill earlier inPATH. Always confirmwhich perlandperl -V | grep use64bitallbeforeperl Makefile.PL. - Skipping the perlconfig eFix. A truncated
Config.pmmakesMakefile.PLemit incomplete compiler flags, leading to link errors that look like compiler problems but are configuration problems. - DB2_HOME not set. Building DBD::DB2 as root without
export DB2_HOME=.../sqllibleaves the driver unable to find DB2 headers and libraries. Set it in the same shell that runs the build. - Using -Duse64bitint instead of -Duse64bitall. Only
use64bitallproduces an interpreter that links against 64-bit DB2 libraries. - Mismatched compiler. If you build modules with a different compiler than the one that built Perl (check
cc=inperl -V), XS objects may not link. Use the same toolchain. - Overwriting the system Perl unintentionally. From-source installs default to a prefix that can clobber the AIX-supplied Perl. Pick a distinct prefix (e.g.
/usr/local) if other tooling depends on the stock interpreter. - Ignoring make test failures. A green
makewith a redmake testalmost always means a broken install at runtime. Resolve test failures beforemake install.
Verification: confirm Perl is 64-bit and DB2 connectivity works
After either option, run these checks to prove the stack is sound:
- Confirm the active interpreter:
which perlreturns the 64-bit binary you intended. - Confirm 64-bit build:
perl -V | grep use64bitallshowsuse64bitall=define. - Confirm DBI loaded:
perl -MDBI -e 'print $DBI::VERSION, "\n";'prints a version number with no errors. - Confirm the driver registered:
perl -MDBI -e 'print join(",", DBI->available_drivers), "\n";'listsDB2among the drivers. - Confirm a live connection (adjust database, user, and password):
perl -MDBI -e 'my $dbh = DBI->connect("dbi:DB2:SAMPLE", "db2inst1", "secret") or die DBI->errstr; print "connected\n"; $dbh->disconnect;'
If step 5 prints connected, your 64-bit Perl is talking to DB2 end to end. If it fails, the error string from DBI->errstr usually names the exact problem (missing catalog entry, bad credentials, or library path), which you can then resolve with db2 catalog commands or by checking LIBPATH.
Key Takeaways
- 64-bit Perl is mandatory to link DBD::DB2 against 64-bit DB2 on AIX 5.2 — verify with
perl -V | grep use64bitallshowinguse64bitall=define. - The pre-packaged Perl 5.8.0 under
/usr/opt/perl5is the recommended route; relink/usr/bin/perlto the_64bitbinaries after applying theperlconfigeFix. - To compile from source, configure with
-Duse64bitall(not-Duse64bitint), thenmake,make test,make install. - Always
export DB2_HOME=.../sqllibbefore building DBD::DB2 as root or a non-instance user, and never skipmake test. - AIX 5.2 and that DB2 era are end of life — reproduce this only for legacy maintenance, and prefer current AIX, Perl, and Db2 for anything new.
Frequently Asked Questions
How do I check if my Perl on AIX is 32-bit or 64-bit?
Run perl -V and look at the use64bitall line. A value of define means a fully 64-bit interpreter; undef means it is not 64-bit. You can also infer it from the pointer and integer sizes reported in the same output.
Why does DBD::DB2 fail to build even though Perl installed fine?
The usual causes are a 32-bit Perl earlier in your PATH, a missing DB2_HOME pointing at sqllib, or a compiler that differs from the one that built Perl. Check which perl, set DB2_HOME, and match the compiler shown in perl -V.
What is the perlconfig eFix and do I still need it?
It repairs a truncated Config.pm in the AIX 5.2 shipped Perl, which otherwise causes module builds to read incomplete configuration. If emgr -l | grep -i perl shows the abstract "fixes truncated Config.pm for Perl" it is already applied; if not, install perlconfig.083004.epkg.Z with emgr -e before building modules.
Should I use the prepackaged Perl or build from source?
Prefer the pre-packaged 64-bit Perl when it exists — IBM built and tested it for the platform, so it is the most supportable. Build from source only when you need a specific Perl version, a custom install prefix, or the packaged interpreter is missing.
For more practical sysadmin and AIX walkthroughs, subscribe on YouTube @explorenystream.