How to find dll's on Cygwin?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

How to find dll's on Cygwin?

Alan W. Irwin
What CMake logic should be used to find the Cygwin dll



I don't have access to Cygwin myself, but my PLplot colleague, Arjen
Markus who does have such access has reported to me off-list that

find_library(GNAT_LIB NAMES gnat gnat-${GNAT_VERSION} gnat-${GNAT_MAJOR_VERSION} cyggnat-${GNAT_MAJOR_VERSION})

does not find /usr/bin/cyggnat-6.dll when GNAT_MAJOR_VERSION is 6.
Note that find was a failure even when he included /usr/bin in

To find dll's this way (rather than import libraries) do I have to use
find_file instead, e.g.,

# Take care of non-Cygwin cases:
find_library(GNAT_LIB NAMES gnat gnat-${GNAT_VERSION} gnat-${GNAT_MAJOR_VERSION})
# Take care of Cygwin case. (Note /usr/bin does not have to be added to
# CMAKE_LIBRARY_PATH for this case.)
find_file(GNAT_LIB NAMES cyggnat-${GNAT_MAJOR_VERSION}.dll)


Or is there some slick way to accommodate both non-Cygwin and Cygwin
platforms with one call to find_library?

<Aside> For a long time it puzzled Arjen and me that our test_ada
project Ada library could be linked with the above dll by hand when
normally you use an import library for that purpose.  But we were
forced to try that because the Cygwin distribution does not provide an
import library corresponding to /usr/bin/cyggnat-6.dll.  And it worked
by hand so now we have to convince CMake to do the same starting with
finding the dll to be used to link our Ada library.

Note the reason why the dll can be used this way is explained with the
following quote from

"If you use the GCC toolchain, incidentally, you don't actually need
import libraries to match your DLLs. The version of the Gnu linker
ported to Windows understands DLLs directly, and can synthesize most
any required stubs on the fly."


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

Powered by

Please keep messages on-topic and check the CMake FAQ at:

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe: