Shared vs Static [WAS: Re: [general] some ideas & request for comments (LONG)]

Charles Wilson
Tue May 16 18:21:00 GMT 2000

Earnie Boyd wrote:
> This is my two cents on naming.
> First I've never really liked the fact that the library names don't reflect
> whether they are static or import dll libs.  So, here is my suggestion for
> naming.
> If the library is an import library to a dll just name it libfoo.dll.a and if
> it is a static library then name it libfoo.a.  I don't like or
> or because the so library is the dynamic library and
> not the import library.

If my patches for binutils are accepted into the cygwin distro, it will
no longer be necessary to USE import libs for the vast majority of dlls.
So, in that sense, if import libs are provided, then they are merely as
a convenience for older compilers -- except in those rare instances
where the import lib does something special. 

So, ordinarily you'd have the following in the library search path
(let's say /usr/lib):

"libfoo.dll" (actually just a symlink to the dll itself, AND the link
target when -Bdynamic; if libfoo.dll [or foo.dll] is not found then the
next choice is libfoo.a)

"libfoo.a" (the static library and only choice for a link target when

"libfoo.dll.a" is kicking around somewhere, but it is not ever used
unless you explicitly say '-lfoo.dll' [SEE NOTE]
In the wierd case, where the import lib actually does something special,
you'd have:

Although "libfoo.dll" is in the PATH (say /usr/bin) it is NOT in the
library search path. No symlink. ld will not find it.

"libfoo.a" the static library is the default link target for both
-Bdynamic (since libfoo.dll & foo.dll can't be found) and -Bstatic.

"libfoo.dll.a" the import library. To link against it, though, you have
to hack the link command to say '-lfoo.dll'

NOTE: Are you suggesting, Earnie, that binutils be further hacked to
search for the following in the '-Bdynamic' case:

'libfoo.dll' 'libfoo.dll.a' (and 'foo.dll' and 'foo.dll.a' for
consistency), and THEN as an absolutely last fallback, 'libfoo.a'

In '-Bstatic', you'd only look for 'libfoo.a' of course.


More information about the Cygwin-apps mailing list