[Top][All Lists]

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

Got shared libraries to build with libtool on MinGW, but it was a strugg

From: Alan W. Irwin
Subject: Got shared libraries to build with libtool on MinGW, but it was a struggle
Date: Thu, 15 Sep 2005 17:58:38 -0700 (PDT)

PLplot ( is a scientific plotting package that uses
libtool (and autoconf and automake) to build the required libraries.  Our
primary platform is Linux, but we are gradually extending our builds to
a large variety of other platforms using the autotools approach.

Early on, we found that shared libraries could not be built on MinGW using
the libtool approach.  However a recent concentrated effort found two issues
whose solution solved the shared library problem on MinGW.

(1) The sed s/^/import/ command (found in the function func_win32_libid
within does not work properly on MinGW so that shared libraries
are never recognized.  The message returned is

"*** Warning: linker path does not have real file for library "

That specific message has some 700 hits on google by a lot of frustrated
libtool users, and I think the following change may satisfy most of their

The solution was to replace

s/^/import/ ==> s/^.*/import/

in func_win32_libid within  Our command-line tests show that the
first command works to insert "import" at the front of even empty lines on
Linux.  This is consistent with the regular expression documentation in
Linux (see info grep ==> regular expressions where it is stated that "^"
specifically matches the empty string at the start of the line).  However,
the result is different for MinGW sed and no match apparently can be made
for the empty anchor "/^/".  The second sed command above actually means
something different; replace the whole pattern buffer with "import".
However, that variation also works with the rest of the sed logic in
func_win32_libid and most importantly works with MinGW; I confirm that
change allows shared libraries to be recognized under MinGW---something that
was impossible with the first form of the above command.

I don't want to over-advocate this solution if it will generate
cross-platform issues, but I don't think it will. The .* regular expression
is pretty ubiquitous for matching zero or more characters.

(2) Like Cygwin (a platform where we can build a shared version of PLplot
without difficulty), MinGW has no shared version of the math library.  It
does have a dummy static version of the math library to work around libtools
needs for static builds on MinGW, but that is a different story.  Since
there is no shared math library even with the above sed change you still get
the same

"*** Warning: linker path does not have real file for library "

message for -lm, and shared libraries crash and burn again on MinGW because
of this.

One (bad) way out of this shared library dilemma is to ask the MinGW
developers to also build a dummy shared math library, but that solution
seems overly-complicated to me, and it is much easier IMO to put MinGW on
the libtool list of platforms without a math library.

I am attaching a 3-line patch to that we are recommending to our
PLplot MinGW users, and which I am also advocating here to allow building of
shared libraries in general with libtool on MinGW.

I have checked that this patch applies cleanly to both in
libtool-1.5.6-6 (the Debian stable version) and libtool-1.5.20.  The 3 lines
of changes would require editing by hand in config/ltmain.m4sh (the script
that appears to generate in libtool-1.9f).

Alan W. Irwin
Alan W. Irwin
email: address@hidden
phone: 250-727-2902

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (; PLplot scientific plotting software
package (; the Yorick front-end to PLplot (; the
Loads of Linux Links project (; and the Linux Brochure Project

Linux-powered Science

Description: patch for for either libtool-1.5.6-6 or libtool-1.5.20

reply via email to

[Prev in Thread] Current Thread [Next in Thread]