Re: Fun with ExtUtils::MakeMaker and Windows import libraries



Ari Jolma <ari jolma tkk fi> writes:

EU::Depends::find_extra_libs assumes now that when OS is MSWin32, the
(import) library extension is ".lib". When MinGW is used, the
extension is usually .dll.a (MinGW could also happily use the actual
.dll, but EU::LibList::Kid does not allow that currently). Thus a
(partial) solution would be to change find_extra_libs to search for
files with .dll.a extension too. I don't have a very elegant solution
how to allow both extensions.

ActiveState seems to support MinGW and automatically detect MinGW
(this is old news
http://www.issociate.de/board/post/274396/ActivePerl_5.8.7.815_released.html).
Somehow this detection should be propagated to EU::LibList::Kid to
look for import libraries "lib<library>.dll.a" -- or the Makefile.PL's
may also alter the liblist by adding ".dll.a" before calling
set_libs().

I also follow your approach on Windows with perl 5.10 built with MinGW.
To find .dll.a libraries I trimmed EU::Liblist::Kid with the patch
below. Changes are only in _win32_ext procedure. Am not sure if cygwin
builts are then ok.

Still, I have to add one line to the $(INST_DYNAMIC) Makefile section
(an example for Glib, similar for Cairo and Gtk2).

$(NOECHO) $(LD) -o Glib.dll $(LDDLFLAGS) $(LDFROM)
-Wl,-out-implib,blib/arch/auto/Glib/Glib.lib $(EXPORT_LIST)
$(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) dll.exp

Probably some changes in EU::MM_Win32 are needed to produce correct
Makefile without the necessity to add an additional line.


--- Kidorig.pm  2008-08-26 19:41:38.669502800 +0000
+++ Kid.pm      2008-08-26 19:54:56.446856800 +0000
@@ -308,12 +308,27 @@
        if (s/^-l// and $GC and !/^lib/i) {
            $_ = "lib$_";
        }
-       $_ .= $libext if !/\Q$libext\E$/i;
+       my ($libext2,$lib1,$lib2);
+       $libext2 = '.dll'.$libext;
+       $lib1 = $_.$libext if !/\Q$libext\E$/i; # .a
+       $lib2 = $_.$libext2 if !/\Q$libext2\E$/i; # .dll.a
 
        my $secondpass = 0;
     LOOKAGAIN:
 
         # look for the file itself
+       if (-f $lib1) {
+           warn "'$thislib' found as '$lib1'\n" if $verbose;
+           $found++;
+           push(@extralibs, $lib1);
+           next;
+       }
+       if (-f $lib2) {
+           warn "'$thislib' found as '$lib2'\n" if $verbose;
+           $found++;
+           push(@extralibs, $lib2);
+           next;
+       }
        if (-f) {
            warn "'$thislib' found as '$_'\n" if $verbose;
            $found++;
@@ -323,7 +338,7 @@
 
        my $found_lib = 0;
        foreach my $thispth (@searchpath, @libpath){
-         unless (-f ($fullname="$thispth\\$_")) {
+         unless (-f ($fullname="$thispth\\$lib1") or (-f ($fullname="$thispth\\$lib2"))) {
            warn "'$thislib' not found as '$fullname'\n" if $verbose;
            next;
          }
@@ -341,7 +356,8 @@
                goto LOOKAGAIN if s/^lib//i;
            }
            elsif (!/^lib/i) {
-               $_ = "lib$_";
+               $lib1 = "lib$lib1";
+               $lib2 = "lib$lib2";
                goto LOOKAGAIN;
            }
        }


-- 
Radek




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]