I installed XAMPP 1.7.4, which includes Perl 5.10.1. I need to connect to a DB2 database, so I installed a DBD::DB2 driver. I then modified the perlinfo.pl test script that comes with XAMPP to pull records from the DB2 database and display them on a web page.

I can run the script from a command window, and it functions correctly, displaying the HTML tags, DB2 data, and perlinfo data.

But, when I run the same script via a browser going to the web server I get the following error message:

Error message:install_driver(DB2) failed: Can't load 'C:/xampp/perl/site/lib//auto/DBD/DB2/DB2.dll' for module DBD::DB2: load_file:The specified module could not be found at C:/xampp/perl/lib/DynaLoader.pm line 200. at (eval 58) line 3 Compilation failed in require at (eval 58) line 3. Perhaps a required shared library or dll isn't installed where expected at C:/xampp/htdocs/xampp/perl-db2.pl line 10 ,

The DB2.dll file is installed exactly where is says it can't load it from. I did observe that when I dumped the CGI environment, the PATH is truncated from what it is supposed to be, and the missing part is all the DB2 directories, but other than that nothing in the missing part seems relevant. The full path is:

I found my answer. It was indeed the PATH variable missing the DB2 directories that was the problem, but in a more interesting way than I thought.

After changing the System environment to move the DB2 entries to the front and not having Apache see the new PATH, I found that the Windows Services reads the environment when it starts at boot time, and every service started after that gets the environment (including PATH) that existed at boot time. Since I had not rebooted after installing DB2 and XAMPP, when the Apache service started, it did not see any of the DB2 PATH entries, so when the Perl DB2.dll tried to load the standard DB2 product dll files, it couldn't find them.

Running it in a cmd window worked because that got the current environment, which included the DB2 dirs.

Guess I've been working on Unix too long. Reboot a server just because you installed software? No -c option for Services? How primitive.