DevOps · K8s · Volleyball · Travel  •  DevOps · K8s · Volleyball · Travel  •  DevOps · K8s · Volleyball · Travel
Explore NY Stream

How to Set Up 64-bit Perl on AIX 5.2

— ny_wk

How to Set Up 64-bit Perl on AIX 5.2

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 sqllib directory (the driver links against headers and libraries there).
  • The GNU make or AIX make available, plus gzip and tar.

Confirm which Perl is currently active and whether it is 64-bit:

  1. Find the interpreter that will be used: which perl
  2. 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):

  1. 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:

IDSTATELABELABSTRACT
1Sperlconfigfixes 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:

  1. Install the eFix: emgr -e perlconfig.083004.epkg.Z
  2. 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:

  1. 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:

  1. Make it runnable: chmod +x switch_perl64.ksh
  2. Run it as root: ./switch_perl64.ksh
  3. Confirm the switch: perl -V | grep use64bitall should show use64bitall=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:

  1. Decompress: gzip -d DBI-1.43.tar.gz
  2. Extract: tar -xf DBI-1.43.tar
  3. Enter the directory: cd DBI-1.43
  4. Generate the Makefile: perl Makefile.PL
  5. Compile: make
  6. Run the test suite: make test
  7. 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:

  1. Set the DB2 home: export DB2_HOME=/home/db2inst1/sqllib
  2. Decompress: gzip -d DBD-DB2-0.78.tar.gz
  3. Extract: tar -xf DBD-DB2-0.78.tar
  4. Enter the directory: cd DBD-DB2-0.78
  5. Read the README — it lists exact system and version requirements.
  6. Generate the Makefile: perl Makefile.PL
  7. Compile: make
  8. Test: make test
  9. 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:

  1. Rename for clarity (example): the downloaded stable.tar.gz becomes perl584.tar.gz.
  2. Decompress: gzip -d perl584.tar.gz
  3. Extract: tar -xf perl584.tar
  4. Enter the source directory: cd perl-5.8.4
  5. 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:

  1. Compile: make
  2. Run the regression tests: make test
  3. Install: make install

Verify the result is genuinely 64-bit:

  1. 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:

  1. gzip -d DBI-1.43.tar.gz
  2. tar -xf DBI-1.43.tar
  3. cd DBI-1.43
  4. perl Makefile.PL
  5. make
  6. make test
  7. make 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:

  1. export DB2_HOME=/home/db2inst1/sqllib (adjust to your instance)
  2. gzip -d DBD-DB2-0.78.tar.gz
  3. tar -xf DBD-DB2-0.78.tar
  4. cd DBD-DB2-0.78
  5. perl Makefile.PL
  6. make
  7. make test
  8. make install

Common pitfalls when building 64-bit Perl and DB2 on AIX

  • Wrong Perl in PATH. The number-one cause of failed driver builds: make runs against a 32-bit perl still earlier in PATH. Always confirm which perl and perl -V | grep use64bitall before perl Makefile.PL.
  • Skipping the perlconfig eFix. A truncated Config.pm makes Makefile.PL emit 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=.../sqllib leaves 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 use64bitall produces 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= in perl -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 make with a red make test almost always means a broken install at runtime. Resolve test failures before make install.

Verification: confirm Perl is 64-bit and DB2 connectivity works

After either option, run these checks to prove the stack is sound:

  1. Confirm the active interpreter: which perl returns the 64-bit binary you intended.
  2. Confirm 64-bit build: perl -V | grep use64bitall shows use64bitall=define.
  3. Confirm DBI loaded: perl -MDBI -e 'print $DBI::VERSION, "\n";' prints a version number with no errors.
  4. Confirm the driver registered: perl -MDBI -e 'print join(",", DBI->available_drivers), "\n";' lists DB2 among the drivers.
  5. 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 use64bitall showing use64bitall=define.
  • The pre-packaged Perl 5.8.0 under /usr/opt/perl5 is the recommended route; relink /usr/bin/perl to the _64bit binaries after applying the perlconfig eFix.
  • To compile from source, configure with -Duse64bitall (not -Duse64bitint), then make, make test, make install.
  • Always export DB2_HOME=.../sqllib before building DBD::DB2 as root or a non-instance user, and never skip make 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.