Date: Fri, 13 Jan 2006 00:04:49 EST-10EDT,10,-1,0,7200,3,-1,0,7200,3600 Subject: [UnixOS2_Archive] No. 678 ************************************************** Thursday 12 January 2006 Number 678 ************************************************** Subjects for today 1 PostgreSQL and Perl : Christian Hennecke" 2 Re: PostgreSQL and Perl : Henry Sobotka 3 Re: PostgreSQL and Perl : Christian Hennecke" 4 Re: PostgreSQL and Perl : Henry Sobotka 5 Re: PostgreSQL and Perl : Christian Hennecke" 6 Re: PostgreSQL and Perl : Dave Yeo" 7 Re: PostgreSQL and Perl : Dave Yeo" 8 Re: PostgreSQL and Perl : Henry Sobotka 9 Re: PostgreSQL and Perl : Christian Hennecke" 10 Re: PostgreSQL and Perl : Dave Yeo" 11 Re: PostgreSQL and Perl : Henry Sobotka 12 Re: PostgreSQL and Perl : Henry Sobotka **= Email 1 ==========================** Date: Wed, 11 Jan 2006 19:13:08 +0100 (CET) From: "Christian Hennecke" Subject: PostgreSQL and Perl I'm trying to setup an open source accounting application call LX Office that uses a web interface and accesses PostgreSQL via Perl as Apache CGI. To do so, one needs to install the DBI module (dbi.perl.org) and a DBD driver. Now I tried to install the module that needs to create a DLL. Somehow the DLL gets created dispite some warnings about unused parameters. Then 2 of the 2190 subtests fail and several tests get skipped. When I subsequently try to "make" the DBD driver which also creates a DLL I get lots of warnings about comparisons between signed and unsigned, and 60 "unresolved external" errors. This is with gcc 3.0.3. Any help would be greatly appreciated. Christian Hennecke **= Email 2 ==========================** Date: Wed, 11 Jan 2006 14:06:05 -0500 From: Henry Sobotka Subject: Re: PostgreSQL and Perl Hi Christian, I also get the 2 failures out of 2,190 and assuming they're the same as you're seeing, they would appear to be cosmetic (expected 0.01, got 1e-02). The unresolved externals indicate you're missing at least one library or the linker isn't finding it or them. If you post the externals, someone here might recognize them. h~ **= Email 3 ==========================** Date: Wed, 11 Jan 2006 20:55:02 +0100 (CET) From: "Christian Hennecke" Subject: Re: PostgreSQL and Perl On Wed, 11 Jan 2006 14:06:05 -0500, Henry Sobotka wrote: Hi Henry, >I also get the 2 failures out of 2,190 and assuming they're the same as >you're seeing, they would appear to be cosmetic (expected 0.01, got 1e-02). I get the following: t/40profile..............NOK 60# Test 60 got: '25 0.93 0.11 1e-02 0.23 1023110000 1023110010' (t/40profile.t at line 202) # Expected: '25 0.93 0.11 0.01 0.23 1023110000 1023110010' # Test 62 got: '27 2.93 0.11 1e-02 0.23 1023110000 1023110010' (t/40profile.t at line 211) # Expected: '27 2.93 0.11 0.01 0.23 1023110000 1023110010' t/40profile..............FAILED tests 60, 62 Failed 2/64 tests, 96.88% okay >The unresolved externals indicate you're missing at least one library or >the linker isn't finding it or them. If you post the externals, someone >here might recognize them. Let's see... Here are some warnings: Pg.xs: In function `XS_DBD__Pg__db_lo_read': Pg.xs:225: warning: comparison between signed and unsigned Pg.xs: In function `XS_DBD__Pg__db_pg_getline': Pg.xs:327: warning: comparison between signed and unsigned Pg.xs: In function `XS_DBD__Pg__db_getline': Pg.xs:345: warning: comparison between signed and unsigned In file included from dbdimp.c:79: large_object.c: In function `dbd_st_blob_read': large_object.c:194: warning: comparison between signed and unsigned large_object.c:203: warning: comparison between signed and unsigned dbdimp.c: In function `_result': dbdimp.c:92: warning: signed and unsigned type in conditional expression dbdimp.c: In function `dbd_st_prepare': dbdimp.c:775: warning: implicit declaration of function `strcasecmp' dbdimp.c: In function `dbd_st_split_statement': dbdimp.c:1139: warning: int format, pointer arg (arg 4) dbdimp.c:1143: warning: int format, pointer arg (arg 5) dbdimp.c: In function `dbd_st_prepare_statement': dbdimp.c:1268: warning: signed and unsigned type in conditional expression dbdimp.c: In function `dbd_bind_ph': dbdimp.c:1311: warning: int format, long unsigned int arg (arg 5) dbdimp.c:1355: warning: comparison between signed and unsigned dbdimp.c:1467: warning: int format, STRLEN arg (arg 6) dbdimp.c: In function `dbd_st_execute': dbdimp.c:1623: warning: int format, STRLEN arg (arg 3) dbdimp.c:1689: warning: int format, STRLEN arg (arg 3) dbdimp.c:1743: warning: signed and unsigned type in conditional expression And a bunch of errors: dbdimp.obj(dbdimp.o) : error L2029: 'PQfreemem' : unresolved external dbdimp.obj(dbdimp.o) : error L2029: 'PQstatus' : unresolved external dbdimp.obj(dbdimp.o) : error L2029: 'PQprepare' : unresolved external dbdimp.obj(dbdimp.o) : error L2029: 'PQendcopy' : unresolved external dbdimp.obj(dbdimp.o) : error L2029: 'lo_close' : unresolved external dbdimp.obj(dbdimp.o) : error L2029: 'PQnfields' : unresolved external dbdimp.obj(dbdimp.o) : error L2029: 'lo_write' : unresolved external dbdimp.obj(dbdimp.o) : error L2029: 'PQuntrace' : unresolved external dbdimp.obj(dbdimp.o) : error L2029: 'PQntuples' : unresolved external dbdimp.obj(dbdimp.o) : error L2029: 'PQoptions' : unresolved external dbdimp.obj(dbdimp.o) : error L2029: 'lo_unlink' : unresolved external dbdimp.obj(dbdimp.o) : error L2029: 'lo_import' : unresolved external dbdimp.obj(dbdimp.o) : error L2029: 'lo_export' : unresolved external dbdimp.obj(dbdimp.o) : error L2029: 'PQgetvalue' : unresolved external dbdimp.obj(dbdimp.o) : error L2029: 'PQoidValue' : unresolved external dbdimp.obj(dbdimp.o) : error L2029: 'PQnotifies' : unresolved external dbdimp.obj(dbdimp.o) : error L2029: 'strcasecmp' : unresolved external dbdimp.obj(dbdimp.o) : error L2029: 'PQsetNoticeProcessor' : unresolved externa Christian Hennecke **= Email 4 ==========================** Date: Wed, 11 Jan 2006 16:04:18 -0500 From: Henry Sobotka Subject: Re: PostgreSQL and Perl Those are long version of the same test failures I'm seeing. Unless your accounting app starts spitting out monetary values in exponential format, I wouldn't worry about it. All but one of the unresolved externals appear to be from libpq (PostgresSQL library). Your linkage command is missing a -L[path to libpq] -llibpq (assuming you have libpq). And #define strcasecmp stricmp should fix the remaining one. h~ **= Email 5 ==========================** Date: Wed, 11 Jan 2006 23:43:23 +0100 (CET) From: "Christian Hennecke" Subject: Re: PostgreSQL and Perl On Wed, 11 Jan 2006 16:04:18 -0500, Henry Sobotka wrote: >Those are long version of the same test failures I'm seeing. Unless your >accounting app starts spitting out monetary values in exponential >format, I wouldn't worry about it. > >All but one of the unresolved externals appear to be from libpq >(PostgresSQL library). Your linkage command is missing a > >-L[path to libpq] -llibpq > >(assuming you have libpq). And The command window says: LD_RUN_PATH="g:/apps/pgsql/lib:e:/emx/lib" gcc -Zdll -Zomf -Zmt -Zcrtdll -s -Zlinker /A:4/E:2 Pg.o dbdimp.o quote.o types.o -O6 -fomit-frame-pointer -malign-double -funroll-loops -ffast-math -finline-functions -mcpu=i686 -s -o blib/arch/auto/DBD/Pg/PgPU.dll e:/Perl/lib/5.8.0/os2/CORE/libperl.lib -Lg:/apps/pgsql/lib -lpq -lsocket -lm -lbsd -lgcc e:/Perl/lib/5.8.0/os2/CORE/libperl_override.lib Pg.def It doesn't make any difference whether it's -llibpq or -lpq. Christian Hennecke **= Email 6 ==========================** Date: Wed, 11 Jan 2006 16:04:26 -0800 From: "Dave Yeo" Subject: Re: PostgreSQL and Perl On Wed, 11 Jan 2006 23:43:23 +0100 (CET), Christian Hennecke wrote: >>(PostgresSQL library). Your linkage command is missing a >> >>-L[path to libpq] -llibpq >> >>(assuming you have libpq). And > >The command window says: > >LD_RUN_PATH="g:/apps/pgsql/lib:e:/emx/lib" gcc -Zdll -Zomf -Zmt >-Zcrtdll -s -Zlinker /A:4/E:2 Pg.o dbdimp.o quote.o types.o -O6 >-fomit-frame-pointer -malign-double -funroll-loops -ffast-math >-finline-functions -mcpu=i686 -s -o blib/arch/auto/DBD/Pg/PgPU.dll >e:/Perl/lib/5.8.0/os2/CORE/libperl.lib -Lg:/apps/pgsql/lib -lpq >-lsocket -lm -lbsd -lgcc >e:/Perl/lib/5.8.0/os2/CORE/libperl_override.lib Pg.def > >It doesn't make any difference whether it's -llibpq or -lpq. Are you mixing Innotek Libc libs with EMX? If so you will have to build a new lib eg (assuming libpq.lib) cp libpq.lib libpq.lib.bak emximp -o libpq.imp libpq.lib emximp -o libpq.def libpq.imp edit libpq.def removing the leading underscore from each export emximp -o pq.lib libpq.def Dave **= Email 7 ==========================** Date: Wed, 11 Jan 2006 16:05:44 -0800 From: "Dave Yeo" Subject: Re: PostgreSQL and Perl On Wed, 11 Jan 2006 23:43:23 +0100 (CET), Christian Hennecke wrote: >It doesn't make any difference whether it's -llibpq or -lpq Forgot to mention it is even easier to just use Innoteks libc Dave **= Email 8 ==========================** Date: Wed, 11 Jan 2006 19:14:35 -0500 From: Henry Sobotka Subject: Re: PostgreSQL and Perl A few possibilities come to mind. Make sure you have an OMF version of libpq (though I think if it weren't you'd see a linker complaint about invalid library). The second is try changing the *nix path separator from ':' to ';' in: > LD_RUN_PATH="g:/apps/pgsql/lib:e:/emx/lib" as it might somehow be screwing things up. You might also try a direct g:/apps/pgsql/lib/pq.lib on the command line instead of -L[path] and -l[lib], and just running the bare gcc command (without the LD_RUN_PATH) by copying it to a .cmd file. Last but hardly least, check what libpq exports; it might be the leading underscore problem. h~ **= Email 9 ==========================** Date: Thu, 12 Jan 2006 02:26:02 +0100 (CET) From: "Christian Hennecke" Subject: Re: PostgreSQL and Perl On Wed, 11 Jan 2006 16:04:26 -0800, Dave Yeo wrote: >Are you mixing Innotek Libc libs with EMX? If so you will have to build a new lib eg >(assuming libpq.lib) >cp libpq.lib libpq.lib.bak >emximp -o libpq.imp libpq.lib >emximp -o libpq.def libpq.imp >edit libpq.def removing the leading underscore from each export >emximp -o pq.lib libpq.def *facepalms* Thanks, together with Henry's hints that did the trick. The DLL is built. So far, the test fail miserably though. Only the very first succeeds. POPUPLOG.OS2 says: 01-12-2006 02:02:34 SYS2070 PID 01d1 TID 0001 Slot 00e1 E:\USR\BIN\PERL.EXE PGPU->LIBPQ.PQerrorMessage 127 Hm, looks like the routine isn't found. Pardon the stupid question but do I have to apply any changes to the libpq.dll as well? Christian Hennecke **= Email 10 ==========================** Date: Wed, 11 Jan 2006 18:29:00 -0800 From: "Dave Yeo" Subject: Re: PostgreSQL and Perl On Thu, 12 Jan 2006 02:26:02 +0100 (CET), Christian Hennecke wrote: >uilt. So far, the test fail miserably though. Only the very first >succeeds. POPUPLOG.OS2 says: > >01-12-2006 02:02:34 SYS2070 PID 01d1 TID 0001 Slot 00e1 >E:\USR\BIN\PERL.EXE >PGPU->LIBPQ.PQerrorMessage >127 > >Hm, looks like the routine isn't found. Pardon the stupid question but >do I have to apply any changes to the libpq.dll as well? Usually you shouldn't but I wouldn't be surprised if sometimes it doesn't work due to libc differences or C++ name mangling. Unluckily the only changes I know of are using the same version of GCC for program and DLL Dave **= Email 11 ==========================** Date: Wed, 11 Jan 2006 23:13:01 -0500 From: Henry Sobotka Subject: Re: PostgreSQL and Perl Dave Yeo wrote: > > Usually you shouldn't but I wouldn't be surprised if sometimes it doesn't work due to libc differences or C++ name mangling. Unluckily the only changes I know of are using the same version of GCC for program and DLL I would think it would create a problem. If a DLL exports _foo, you can link successfully by changing the def file and lib to say it exports foo, but a runtime call to foo will fail without an intervening mechanism to prepend the underscore (or export by ordinals). Christian, rather than rebuild libpq, you can take the def file without the underscores that you used for linkage, and change it, e.g. EXPORTS foo=_foo bar=_bar The first is the exports name, the second the internal name. Then rebuild the lib and relink the DBI driver. The Perl script below should save you a bit of typing. It expects the name of the DEF file as arg, e.g. perl fixps foo.def, and outputs newfoo.def. h~ ------------------ fixps --------------------------------------- #!Perl -w # -*- Mode: perl; indent-tabs-mode: nil -*- use strict; my $file = $ARGV[0]; open DEF, "<$file" or die "Can't open $file: $!\n"; my at defs = ; close DEF; my at exps; foreach my $e ( at defs) { $e =~ s/^(\s+"(\w+)).*$/$1"="_$2"/; push at exps, $e; } open DEF, ">new$file" or die "Can't open $file: $!\n"; print DEF at exps; close DEF; ------------------- ciao --------------------------------------- **= Email 12 ==========================** Date: Wed, 11 Jan 2006 23:30:56 -0500 From: Henry Sobotka Subject: Re: PostgreSQL and Perl Just an afterthought. I started wondering if it should be: EXPORTS "foo"="_foo" or "foo=_foo" The toolkit doc on DEF files says nothing about the quotation marks that emxexp outputs, and the example doesn't use any, so they may be irrelevant. Anyhow, changing the regex line in the script to $e =~ s/^(\s+"(\w+)).*$/$1=_$2"/; will output the latter in case the quotation marks matter. h~