Subject: Re: The Black Art of DLL Creation (revisited)
From: "Gerrit P. Haase" <[email-masked]>
To: Soren A <[email-masked]>
Cc: [email-masked]
Date: Fri, 22 Nov 2002 23:23:53 +0100

Hallo Soren,

> Taking apart the current build setup, we see that dlltool (through dllwrap)
> is invoked for building the shared Perl library

That is not correct.  At first a static lib is created:

/bin/ar rcu libperl.a perl.o malloc.o gv.o toke.o perly.o op.o pad.o regcomp.o dump.o util.o mg.o reentr.o hv.o av.o run.o pp_hot.o sv.o pp.o scope.o pp_ctl.o pp_sys.o doop.o doio.o regexec.o utf8.o taint.o deb.o universal.o xsutils.o globals.o perlio.o perlapi.o numeric.o locale.o pp_pack.o pp_sort.o cygwin.o

Second, miniperl.exe is linked withthis static lib:

gcc -L/sourcecode/perl/perl59  -g -L/usr/local/lib -o miniperl miniperlmain.o opmini.o -lperl -lm -lc -lcrypt -lutil -lbinmode

Last, a shared libperl with importlib is created:

gcc -shared -o  cygperl5_9_0.dll -Wl,--out-implib=libperl.dll.a -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--stack,8388608 \
-g -L/usr/local/lib  perl.o malloc.o gv.o toke.o perly.o op.o pad.o regcomp.o dump.o util.o mg.o reentr.o hv.o av.o run.o pp_hot.o sv.o pp.o scope.o pp_ctl.o pp_sys.o doop.o doio.o regexec.o utf8.o taint.o deb.o universal.o xsutils.o globals.o perlio.o perlapi.o numeric.o locale.o pp_pack.o pp_sort.o cygwin.o -lm -lc -lcrypt -lutil -lbinmode
Creating library file: libperl.dll.a

No dlltool or dllwrap is involved here.

[...dlltool..deffile...problems...snipped...]

Take a look in <topsourcedir>/cygwin/perlld and see:

# if some of extensions are undefined,
# no corresponding output will be done.
# most probably, you'd like to have an export library
# my $DEF_EXT = '@DEF_EXT@';
# my $EXP_EXT = '@EXP_EXT@';
my $LIB_EXT = '@LIB_EXT@';

#my $DEBUG ="perlld.out";
my $DEBUG =undef;

you may comment/uncomment the according lines to get a .def, .exp,
debug output file. This will be passed to gcc as usual which
passes it to ld:

  $command ="$CC -shared -o  $dllname";
#  $command .=" --verbose" if $verbose;

  $command .=" -Wl,--output-def=$libname$DEF_EXT" if $DEF_EXT;
  $command .=" -Wl,--output-exp=$libname$EXP_EXT" if $EXP_EXT;
  $command .=" -Wl,--out-implib=$libname.dll$LIB_EXT" if $LIB_EXT;
  $command .=" -Wl,--export-all-symbols" if $EXPORT_ALL;
  $command .=" -Wl,--enable-auto-import -Wl,--stack,8388608"; # always

There should be correct .def and .exp files then.

Gerrit
-- 
=^..^=

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/