Thread: linker (ld2/dllwrap) error for PL/Perl using Cygwin port

linker (ld2/dllwrap) error for PL/Perl using Cygwin port

From
"Edward Q. Bridges"
Date:
I've successfully gotten Postgres working on a cygwin port,
and am now trying to get PL/Perl to work as well.

(PL/Perl is a plugin to the Postgres Database which allows
one to create functions within the RDBMS written in Perl)

Here are the specs:
Windows NT Workstation, 4.0 (S.P. 6a)
Cygwin DLL v. 1.1.4(0.2632)
Postgres 7.02
Perl 5.6.0
CygIPC 1.07-1

I followed the instructions for installing Postgres at this url:
http://people.freebsd.org/~kevlo/postgres/portNT.html

And I used the binary perl distribution from here:
http://cygutils.netpedia.net/V1.1/perl-5.6.0/index.html
   (When trying to configure the sources i get an "Invalid DLL
    Entrypoint" popup error msg from "fred.exe,"  to wit:
       "The dynamic link library C:\cygwin\tmp\perl-5.6.0\UU\dyna.dll is not
        written correctly.  The stack pointer has been left in an inconsistent
        state.  The entrypoint should be declared as WINAPI or STDCALL.  Select
        YES to fail the DLL load.  Select NO to continue execution.  Selecting
        NO may cause the application to operate incorrectly."
    When I answer NO to the dialog, I get a response from the Configure program
    that "Perhaps you should not use dynamic loading.", which evidently is necessary
    for PL/Perl.)

I created symlinks to the perl dll:
$ cd /usr/local/lib/perl5/5.6.0/cygwin/CORE
$ ln -s libperl5_6_0.dll libperl.dll
 (... ditto for libperl.a and libperl.def...)
$ cd /usr/local/bin
$ ln -s libperl5_6_0.dll libperl.dll


Anyway, when I goto $POSTGRES_SRC/src/pl/plperl and run
$ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/perl5/5.6.0/cygwin/CORE:/usr/local/bin \
  perl Makefile.PL POLLUTE=1
$ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/perl5/5.6.0/cygwin/CORE:/usr/local/bin \
  make
I get the messages appended at the end of the email.  I'm having trouble deciphering
these messages and determining whether this is a "Cygwin" issue or a "PLPerl" issue.

My questions:
*  Is this a problem with cygwin's ld2 or dllwrap?  or is it a problem where the perl distro
   i am using didn't have an "export definition file" with it?  or ???
*  What can I do to fix it :)

Thanks!!!
ed



$ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/perl5/5.6.0/cygwin/CORE:/usr/local/bin make
mkdir blib
mkdir blib/lib
mkdir blib/arch
mkdir blib/arch/auto
mkdir blib/arch/auto/plperl
mkdir blib/lib/auto
mkdir blib/lib/auto/plperl
gcc -c -I../../../src/include -I../../../src/backend -I/usr/local/include -fno-strict-aliasing -I/us
r/local/include -DPERL_POLLUTE  -DUSEIMPORTLIB -O     -DVERSION=\"0.10\" -DXS_VERSION=\"0.10\"  -I/u
sr/local/lib/perl5/5.6.0/cygwin/CORE  plperl.c
In file included from plperl.c:76:
/usr/local/lib/perl5/5.6.0/cygwin/CORE/perl.h:2027: warning: `DEBUG' redefined
../../../src/include/utils/elog.h:22: warning: this is the location of the previous definition
gcc -c -I../../../src/include -I../../../src/backend -I/usr/local/include -fno-strict-aliasing -I/us
r/local/include -DPERL_POLLUTE  -DUSEIMPORTLIB -O     -DVERSION=\"0.10\" -DXS_VERSION=\"0.10\"  -I/u
sr/local/lib/perl5/5.6.0/cygwin/CORE  eloglvl.c
/usr/local/bin/perl -I/usr/local/lib/perl5/5.6.0/cygwin -I/usr/local/lib/perl5/5.6.0 /usr/local/lib/
perl5/5.6.0/ExtUtils/xsubpp  -typemap /usr/local/lib/perl5/5.6.0/ExtUtils/typemap SPI.xs > SPI.xsc &
& mv SPI.xsc SPI.c
gcc -c -I../../../src/include -I../../../src/backend -I/usr/local/include -fno-strict-aliasing -I/us
r/local/include -DPERL_POLLUTE  -DUSEIMPORTLIB -O     -DVERSION=\"0.10\" -DXS_VERSION=\"0.10\"  -I/u
sr/local/lib/perl5/5.6.0/cygwin/CORE  SPI.c
In file included from SPI.xs:41:
/usr/local/lib/perl5/5.6.0/cygwin/CORE/perl.h:2027: warning: `DEBUG' redefined
../../../src/include/utils/elog.h:22: warning: this is the location of the previous definition
Running Mkbootstrap for plperl ()
chmod 644 plperl.bs
LD_RUN_PATH="" ld2 -o blib/arch/auto/plperl/plperl.dll  -L/usr/local/lib plperl.o eloglvl.o SPI.o /u
sr/local/lib/perl5/5.6.0/cygwin/auto/Opcode/Opcode.dll -L/usr/local/lib/perl5/5.6.0/cygwin/CORE -lpe
rl  /usr/local/lib/perl5/5.6.0/cygwin/CORE/libperl5_6_0.a
dllwrap --dllname plperl.dll --driver-name gcc --dlltool dlltool --export-all-symbols --as as --outp
ut-def libplperl.def --output-lib libplperl.a \
 -L/usr/local/lib plperl.o eloglvl.o SPI.o /usr/local/lib/perl5/5.6.0/cygwin/auto/Opcode/Opcode.dll
-L/usr/local/lib/perl5/5.6.0/cygwin/CORE -lperl /usr/local/lib/perl5/5.6.0/cygwin/CORE/libperl5_6_0.
a
dllwrap: no export definition file provided
dllwrap: creating one, but that may not be what you want
/usr/bin/ld: warning: cannot find entry symbol __cygwin_dll_entry@12; defaulting to 62881000
plperl.o(.text+0x1d4):plperl.c: undefined reference to `elog'
.
. [ lots of "undefined reference" messages deleted ]
.
plperl.o(.text+0x1526):plperl.c: undefined reference to `MemoryContextFree'
SPI.o(.text+0xf3):SPI.c: undefined reference to `elog'
collect2: ld returned 1 exit status
dllwrap: gcc exited with status 1
perlld: *** system() failed to execute
dllwrap --dllname plperl.dll --driver-name gcc --dlltool dlltool --export-all-symbols --as as --outp
ut-def libplperl.def --output-lib libplperl.a \
 -L/usr/local/lib plperl.o eloglvl.o SPI.o /usr/local/lib/perl5/5.6.0/cygwin/auto/Opcode/Opcode.dll
-L/usr/local/lib/perl5/5.6.0/cygwin/CORE -lperl /usr/local/lib/perl5/5.6.0/cygwin/CORE/libperl5_6_0.
a

make: *** [blib/arch/auto/plperl/plperl.dll] Error 1