[1.7] /usr/bin no longer in default LD_LIBRARY_PATH

Yaakov (Cygwin/X) yselkowitz@users.sourceforge.net
Thu Mar 19 17:55:00 GMT 2009

Hash: SHA256

Corinna Vinschen wrote:
> If a DLL can't be found in a given PATH, Cygwin 1.5.25's function
> searching for the DLL (get_full_path_of_dll) just left the filename
> alone.  The following LoadLibrary call then used the default DLL search
> order, which includes the $PATH variable, thus a DLL in /usr/bin is
> found.
> Since July last year, Cygwin 1.7's get_full_path_of_dll function always
> converts a filename to a full pathname, even if the file isn't found.
> The resulting full pathname is $cwd/filename.  This effectlvely
> suppresses the Win32 default DLL search path in LoadLibrary, thus using
> either LD_LIBRARY_PATH, or /usr/lib.  From a POSIX perspective it's
> wrong to rely on the default Win32 DLL load order in dlopen() and the
> behaviour of dlopen() in 1.5.25 was a bug rather than a feature.
> Bottom line is, I'm sure the new behaviour is more correct, but if
> you have a convincing argument to revert to the old behaviour, I'm
> certainly open for discussion.

First, it's a huge regression.  This breaks *lots* of existing code.

Now, at risk of stating that which you already know quite well:

Using /usr/lib as the default LD_LIBRARY_PATH makes sense on *NIX
platforms where the shared libraries are themselves in PREFIX/lib, and
LD_LIBRARY_PATH is used not only by dlopen() but by ld.so for runtime
linking as well.

It goes without saying that this is not the case on Cygwin.  We rely on
Windows' runtime linker, which resolves using PATH.  Therefore we put
all our shared libraries in PREFIX/bin, which anyways need to be in PATH
to run commands from there.

Being so, WRT dlopen(), it doesn't make much sense to look in /usr/lib
for libraries which aren't there!  In fact, among the many packages in
Ports, only four packages install their DLL modules directly into
/usr/lib, and three of those use libltdl anyway (which, BTW, uses PATH
on Cygwin instead of LD_LIBRARY_PATH for resolving DLLs!).

So as it stands now, dlopen() finds, well, just about nothing.

How could we proceed?

We could keep the code as is, but since we install DLLs to /usr/bin and
add it to PATH, we need to add it to LD_LIBRARY_PATH as well.  Those who
add /usr/local/bin (or ~/bin) to their PATH will need to add it to their
LD_LIBRARY_PATH also, so you end up with nearly identical PATH and

OR we could revert the code to allow searching in PATH as before, since
that's where the DLLs actually reside.

Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

More information about the Cygwin mailing list