dbi-users  

Informix DBD (on Win2k) build problems and solutions (or saving the world)

Brian Campbell
Wed, 14 Jan 2004 02:53:10 -0800

Last fall (2003), I built the DBD for Informix for two releases of Perl 5.6.1 and 5.8. 
 I ran into a number of problems, but managed to fix or work around them.  Below, 
following Tim's excerpt (and urging), is a detailed report of things I had to do to 
get this build to work.  It's similar to the one I send Jonathan in November.  While I 
was experienced in general Perl programming, keep in mind that I was new to the whole 
DBI/DBD/Makefile tool suite, so some of my solutions may less than optimal.  Actually, 
I know some are less.

There were problems in the DBD build script (Makefile.pl) which will interest some 
people in the DBI users mail group, and there were problems in Perl libs themselves 
(incl. at least CPAN, Config, Test, and ExtUtils) which presumably will interest some 
people in the perl5 porters group.  I am under the impression that the Informix DBD 
build package is a variation of some general base DBD build process, which I seem to 
recall also makes use of Perl lib MakeMaker utility.  Assuming that this is all true, 
then I'm not sure which of the DBD build script problems are under the responsibility 
of Jonathan (Informix variant), which are due to the DBD "base" package, and which are 
due to the MakeMaker.  I'll let greater minds than mine (e.g. Jonathan, Tim) sort all 
that out. 

The majority of the problems I ran into is lack of support of the "space" character in 
filenames.  While this is an uncommon situation in the Unix world, it is common in the 
PC world.   This is not meant to reflect badly on the designers of the affected 
software.  My own experience shows that it's an easy thing to overlook and you really 
have to be cognizant of this issue at every file name reference.  See my comments in 
the excerpt below.

----- Original Message ----- 
From: Tim Bunce <[EMAIL PROTECTED]>
To: Brian Campbell <[EMAIL PROTECTED]>
Cc: Jonathan Leffler <[EMAIL PROTECTED]>; BAFFIGI, Christian <[EMAIL PROTECTED]>; DBI 
Users <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, January 13, 2004 6:54 AM
Subject: Space in installation directory name causes problems


> On Mon, Jan 12, 2004 at 05:03:52PM -0700, Brian Campbell wrote:
> > Some advice: Make sure your perl installation is not in the "Program Files"
> > or any directory that has a "space" in the name.  I think ActiveState Perl
> > defaults
> > Perl to an installation location of "C:\Perl", but per IT policy at our
> > site, our
> > site-specific installation process places all apps in "C:\Program Files",
> > e.g. "C:\Program Files\Perl".
> > 
> > The DBD make process makes several references to this path but does not
> > support blanks (that
> > is, there are several points where the process breaks or fails when it
> > encounters such a path).
> > Furthermore, the make process calls Perl utility packages which use this
> > path and I found that
> > the packages don't support blanks either (same symptoms).   I managed to
> > find and fix several of
> > the "bugs" in the make code and Perl packages, and developed work-arounds in
> > other cases.
> > This path issue accounted for the majority of build problems I ran into.
> 
> Please help "save the world" by sending fixes to the relevant people.
> 
> Here for DBI and DBD Makefile.PL changes and [EMAIL PROTECTED]
> for changes to ExtUtils::MakeMaker. Even if you can't fix the whole
> problem any progress helps and also keeps the issue alive.
> 
> Tim.


--------------------------------------------------------------------------------


By popular demand (or at least Tim's demand) here are the details...

Here is a description of all the things I did to get the Informix DBD driver working 
on my machine.  These things fall into 3 categories: 
  a.. Suggested Fixes/changes to the DBD build distribution
  b.. Suggested Fixes/changes to called Perl lib modules
  c.. Other helpful Tips/Tricks
My platform consists of: 
  a.. Windows 2000 [Version 5.00.2195] SP3
  b.. ActiveState Perl MSWin32-x86-multi-thread (both 5.6.1 and  5.8 - I found and 
solved the problems in 5.6.1 and unless otherwise noted, I applied the same solutions 
in 5.8).
  c.. ESQL: IBM Informix CSDK Version 2.81, IBM Informix-ESQL Version 9.53.TC1
  d.. Microsoft Visual C++ 6.0
  e.. Cygwin (Unix command clone package from Cygnus)
  f.. Connection to Informix DB server 9.21.FC4 on an Alpha box running Compaq Tru64 
Unix.
The majority of problems were due to scripts not supporting file names with spaces.  
Unless otherwise noted, each solution adds quotes around application name that 
includes a space (Program Files), or a changes the name to include the alternate "DOS 
short name" (Progra~1 on most machines).  The quoting method is preferred, and I used 
it when ever I could identify a source location for the reference and found a quoting 
mechanism that would work.  This implies that the "short name fixes" are due to my 
lack of persistence & time in identifying proper "quote fixes".  The mapping of 
"Program Files" to Progra~1, while common on most systems, I believe is not 
guaranteed, which makes this a poor candidate for providing a "general solution". 

Fixes to the DBD build process that creates the makefile
It's not clear which solutions in the first part of this section are specific to the 
Informix variant and which apply to other DBD variants, or even the Perl Maker utility.

I changed the supplied app Makefile.pl in the DBD build distribution. First,  I 
commented sections bounded by: #-HERE-# and #-AND-HERE-#.   I'm not sure what this is 
all about, but the comments suggested that if this code gives me grief, then I should 
comment.  It did and I did.  Other changes to Makefile.pl were due to the space 
problem: 
  a.. changed (from/to): 
    a.. $EQ = $esql; 
    b.. $EQ = "\"$esql\""; 
  b.. changed (from/to): 
    a.. my $libs = `$esql -libs` || die "Couldn't execute 'esql -libs'"; 
    b.. my $libs = `"$esql" -libs` || die "Couldn't execute 'esql -libs'"; 
  c.. changed (from/to): 
    a.. system "$^X t/dtgen.pl > t/dtgen.sql"; 
    b.. system "\"$^X\" t/dtgen.pl > t/dtgen.sql"; 
  d.. changed (from/to): 
    a.. system "$^X t/decgen.pl > t/decgen.sql"; 
    b.. system "\"$^X\" t/decgen.pl > t/decgen.sql"; 
I changed the supplied module DBD/Informix/Configure.pm: 
  a.. changed (from/to): 
    a.. open(ESQL, "$esql -V|") || die; 
    b.. open(ESQL, "\"$esql\" -V|") || die; 
I had to make changes to the Perl libraries in my Perl installation.  The Cygwin and 
MSVC comments are important hints to would-be Win2K/DBD builders.  All the other 
comments are filename "space" fixes or workarounds, mostly the latter.  These fixes 
are outside the scope of the DBD and will interest some perl5-porters.
  a..  C:\Program Files\Perl\lib\CPAN\Config.pm 
    a.. I hadn't used this module before, so I needed to modify/add a number of 
settings.  See my result at the end of this document.
    b.. I globally changed "Program Files" to "PROGRA~1".  This avoided having to find 
all the pertinent references and adding quote fixes to them. 
    c.. I depended on my Cygwin installation for a number of listed apps.  Apparently 
you can't use the CPAN functionality (which Makefile.pl seems to require) unless you 
have a suite of Unix tools on your Windows machine (like Cygwin).  I believe had had 
to use another short name (Micros~4) in lieu of another space infested name "Microsoft 
Visual Studio". 
    d.. The nmake entry needs to point to the tool in the MSVC++ Bin folder. 
  b.. C:\Program Files\Perl\lib\CPAN.pm, changed from/to: 
      a.. $system = "$perl $switch Makefile.PL $CPAN::Config->{makepl_arg}"; 
      b.. $system = "\"$perl\" $switch Makefile.PL $CPAN::Config->{makepl_arg}"; 
  c.. C:\Program Files\Perl\lib\ExtUtils\MM_Win32.pm (this is a workaround, not a real 
solution).
    a.. Perl 5.6: 
      a.. inserted:    $abs =~ s/Programs Files/PROGRA~1/; 
      b.. above this statement:    $val = `$abs -e "require $ver"; 2>&1`; 
    b.. Perl 5.8: 
      a.. inserted: $safe_abs =~ s/Program Files/PROGRA~1/; 
      b.. above this statement: $val = `$safe_abs -e "require $ver;" 2>&1`; 
  d.. C:\Program Files\Perl\lib\Config.pm, changed from/to (another workaround): 
    a.. privlibexp='C:\Program Files\Perl\lib' 
    b.. privlibexp='C:\Progra~1\Perl\lib' 

In spite of all the the above fixes, the generated "C" makefile that was created had a 
number of "Program Files" references (space in the file names).  The preferred 
solution would be to figure out the correct quote syntax you need in the makefile, and 
have the Makefile.pl app generate this syntax where appropriate.   I opted for a quick 
fix:  I post-processed the Makefile with this perl script: 

    use strict; 
    open MF, "Makefile"; 
    my @lines = <MF>; 
    close MF; 
    open MF, ">Makefile"; 
    map (s/Program Files/PROGRA~1/g, @lines); 
    print MF @lines; 
    close MF; 

Issues regarding running makefile to build the DBD
I believe that the points in this section would be primarily of interest to "would-be" 
DBD-on-Win2K builders, or Informix DBD builders. 

My MSVC++ installation process apparently did not update my PATH to support the 
compiler command line tools needed by the esql test and build processes.  Your mileage 
may vary.  I manually added these folders to my PATH: 
  a.. C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin 
  b.. C:\Program Files\Microsoft Visual Studio\VC98\bin 
I encountered and ignored warnings found in a number of c modules similar to the 
following.  Hopefully that was OK. 
  a.. dbdimp.ec(1576) : warning C4090: 'function' : different 'const' qualifiers 
  b.. dbdimp.ec(1576) : warning C4024: 'strlen' : different types for formal and 
actual parameter 1 
Issues and Tips while running the makefile to run the test suite
Changed another perl module (of interest to perl5-porters): 
  a.. Perl 5.6: C:\Program Files\Perl\lib\Test\Harness.pm, from/to: 
    a.. "$^X $s $test|"; 
    b.. "\"$^X\" $s $test|"; 
  b.. Perl 5.8: C:\Program Files\Perl\lib\Test\Straps.pm, from/to: 
    a.. my $cmd = $self->{_is_vms} ? "MCR $^X" : ^X; 
    b.. my $cmd = $self->{_is_vms} ? "MCR $^X" : "\"$^X\""; 
I fixed a ubiquitous runtime crash in: dbdimp.ec (of interest to Win2K Informix DBD 
builders):

  a.. Added this above the function: count_descriptors 
    a.. #define PERL_OBJECT 
  b.. This forces a call to SqlFreeMem instead of free per PTS Bug B83831. This must 
be place "low" in the file; placing this high in the file cause compile errors on 
includes. 
The rest of these points are primarily of interest to Informix DBD builders, perhaps 
on any platform:
  a.. At least one of the test plans required the database output format yyyy-mm-dd 
which different from the default mm/dd/yy.  I tried to set the env var DBDATE.  I 
found conflicting documentation on the syntax of DBDATE's value, and neither format 
worked for me.  I finally stumbled across GL_DATE and it's format.  I used that and 
the test plans finally worked (double percents required per DOS .BAT syntax).
    a.. SET GL_DATE=%%Y-%%m-%%d 
  b.. One of the test plans uses Informix's SPSPACE feature by default.  My test 
database didn't have that enabled.  I found that I could add this env var to bypass 
the use of SPSPACE and "pass" the test plan: 
    a.. SET DBD_INFORMIX_NO_SBSPACE=1 
  c.. When a test plan failed while running the suite (via nmake test), it was not 
apparent why.  I found that running the test plan individually as follows produced 
informative information.  Perhaps there is support in the makefile for this.  I didn't 
check. 
    a.. perl -Mblib t\t51getinfo.t 
  d.. Three of the test plans don't run successfully if run as part of the suite (via 
nmake test).  But apparently they run fine individually as per previous bullet.  I 
have not analyzed the testplans to understand why they fail in the suite.  They are: 
    a.. t\t51getinfo.t 
    b.. t\t58typeinfoall.t 
    c.. t\t99clean.t

A General Win2K Tip
I found that running the Makefile.pl app and nmake from a .BAT script was more 
convenient.  I could easily add and tweak environment variables without the overhead 
of changing my system variables.  Sample BAT script. 

@ECHO OFF 
PATH %PATH%;C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program 
Files\Microsoft Visual Studio\VC98\bin 
SET INFORMIXDIR=C:\Progra~1\Informix\Client-SDK 
SET INFORMIXSERVER=production 
SET DBI_DBNAME=brian 
SET DBD_INFORMIX_DATABASE=brian 
SET DBD_INFORMIX_USERNAME=campbelb 
SET DBD_INFORMIX_PASSWORD=xxxxx 
SET DBD_INFORMIX_DEBUG_ESQLTEST=1 
SET GL_DATE=%%Y-%%m-%%d 
SET DBD_INFORMIX_NO_SBSPACE=1 
perl Makefile.pl 
perl fixMakefile.pl 
nmake 
nmake test 
perl -Mblib t\t51getinfo.t 
perl -Mblib t\t58typeinfoall.t 
perl -Mblib t\t99clean.t 
rem nmake install 
pause 
  

My Configuration Hash in CPAN/Config.pm (using Cygwin and MSVC)

$CPAN::Config = { 
  'build_cache' => q[40], 
  'build_dir' => q[C:\Perl_cpan\build], 
  'cache_metadata' => q[1], 
  'cpan_home' => q[C:\Perl_cpan], 
  'dontload_hash' => {  }, 
  'ftp' => q[C:\progra~1\cygwin\bin\ftp.exe], 
  'ftp_proxy' => q[], 
  'getcwd' => q[cwd], 
  'gzip' => q[C:\progra~1\cygwin\bin\gzip.EXE], 
  'http_proxy' => q[], 
  'inactivity_timeout' => q[0], 
  'index_expire' => q[1], 
  'inhibit_startup_message' => q[0], 
  'keep_source_where' => q[C:\Perl_cpan\sources], 
  'lynx' => q[C:\progra~1\cygwin\bin\lynx.exe], 
  'make' => q[C:\progra~1\Micros~4\VC98\Bin\nmake.exe], 
  'make_arg' => q[], 
  'make_install_arg' => q[], 
  'makepl_arg' => q[], 
  'ncftpget' => q[C:\progra~1\cygwin\bin\ncftpget.exe], 
  'no_proxy' => q[], 
  'pager' => q[C:\WINNT\system32\more.COM], 
  'prerequisites_policy' => q[ask], 
  'scan_cache' => q[atstart], 
  'shell' => q[C:\progra~1\cygwin\bin\bash.exe], 
  'tar' => q[C:\progra~1\cygwin\bin\tar.exe], 
  'term_is_latin' => q[1], 
  'unzip' => q[C:\progra~1\cygwin\bin\unzip.exe], 
  'urllist' => [q[http://www.perl.com/CPAN/]], 
  'wait_list' => [q[wait://ls6.informatik.uni-dortmund.de:1404]], 
  'wget' => q[C:\progra~1\cygwin\bin\wget.exe], 
}; 
1; 
__END__