That sounds like you have made great progress.

How exactly do I get cmake to filter out the -lm option?

On Wed, May 14, 2014 at 4:32 AM, Alan W. Irwin <> wrote:
On 2014-05-13 18:38-0700 Alan W. Irwin wrote:

On 2014-05-13 11:15-0700 Alan W. Irwin wrote:

Note, I have never gotten a downloaded binary version of GTK+ to work
properly with PLplot on MinGW/Wine because of ABI incompatibility
issues (my fairly recent version of MinGW was always ABI inconsistent
with the typically extremely old version of MinGW used to build GTK+),
but maybe I will finally get lucky this time.  Anyhow, so far so good,
and more later as this experiment on Wine unfolds.

Hi Walt:

Six hours later (because the builds of PLplot dependencies on Wine are
really slow for the reasons I mentioned and one false start that
wasted a couple of hours) I finally got to the point of building
PLplot using the "MinGW Makefiles" generator against epa_built
versions of all its dependencies other than the GTK+ stack and the
official 32-bit binary version of GTK+ for Windows which is supposed
to be compatible with MinGW.

The result verified the PLplot "MinGW Makefiles" build-system issue that Walt found
previously on Microsoft Windows (which also verifies once again that
Wine is a fairly reliable but slow! Windows test platform); for some
strange reason parts of the GTK+ stack are being found by pkg-config but
other parts are not being found so the overall effect is the cairo
devices are all being dropped.  This pkg-config result works fine on
Linux so the whole thing is quite a puzzle.

I will look further at this tomorrow (Wednesday) now I have confirmed
this Windows platform PLplot build-system (or perhaps pkg-config)
issue for the PLplot pango/cairo stack dependencies.

The issue turned out to be due to a GTK+ pkg-config configuration file bug
where -lm is automatically added to the library links, e.g.,

bash.exe-3.1$ pkg-config --libs pangocairo
-Lz:/home/wine/gtkplus/3.6.4/lib -lpangocairo-1.0 -lcairo

-lpangoft2-1.0 -lfreetype -lfontconfig -lpangowin32-1.0 -lgdi32
-lpango-1.0 -lm -lgobject-2.0 -lglib-2.0 -lintl

But the math library does not exist separately on Windows platforms so
-lm should not be part of the link flags delivered by "pkg-config
--libs pangocairo" (or the results of the equivalent CMake command
which uses pkg-config internally).

As a workaround (revision 13116) for this gtk+ bug, I have filtered
-lm out of the above library flags for the Windows case (where the
cmake MATH_LIB variable is false).  As a result of this fix, cmake now
configures the cairo device without issues for the "MinGW Makefiles"

After that fix, I also ran into a number of additional minor build
system issues for the "MinGW Makefiles" case and the cairo device
driver case.  (The reason those issues existed is because that
combination had not been tried in years.) I believe all of those
issues are fixed now (revision 13119), and, for example, I can build
(N.B. you must use the -DTEST_DYNDRIVERS=OFF cmake option) and run the
wincairo device by hand without issues.

So Walt, you should be able to do that now as well, but please let
me know if you spot any other issue.  And thanks for being persistent
with this issue so I finally fixed it!  :-)

To everyone here, all preliminary indications are that (at least with
MinGW-4.7.2 which is the version I am using) the official 32-bit
binary download of cairo works well without ABI issues with PLplot.
This is a first for me.  :-)

I am now following up this cairo device driver success on MinGW by
starting a comprehensive interactive and non-interactive test on Wine
using the "MinGW Makefiles" generator and MSYS (a special version
without sh.exe in the PATH, see cmake/epa_build/README for how to
achieve that and why it is necessary).  The PLplot dependencies for
this test will be the binary download of gtk+ + epa_build of
everything else.  This test should take overnight on Wine, but it
should take roughly one-half hour on Microsoft Windows if anyone is
interested in following the directions in cmake/epa_build/README.

Alan W. Irwin

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

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (; the Time
Ephemerides project (; PLplot scientific plotting
software package (; the libLASi project
(; the Loads of Linux Links project (;
and the Linux Brochure Project (

Linux-powered Science

Walt Brainerd