This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc -mno-cygwin still wants to link with cygwin libs


Peter Amstutz wrote:

> However, the real problem is that when ld searches the linker path, it
> seems to do so in several phases, and is the way this search works is
> troublesome.  I should note that it does find files that end it ".lib",
> but only AFTER it has searched the ENTIRE path for files ending in
> ".dll.a".  What this means is that "libjpeg.dll.a" from cygwin, although
> at the very end of the search path, is found and matched before
> "jpeg.lib", which is at the very beginning of the search path, but the
> misfortune of having the wrong name and relegated to the second search
> pass.  It is discriminated against.  If I rename "jpeg.lib" to
> "libjpeg.dll.a", it finds the correct link library at the correct
> location.

The search order is documented:
<http://sourceware.org/binutils/docs-2.16/ld/WIN32.html#index-direct-linking-to-a-dll-527>.

My advice is just specify the filename of the library directly, without
flags, e.g. "/path/to/file.lib" and don't try to use -L or -l.  There
should be zero ambiguity if you do this.

> used by several different compilers, so I'm trying to avoid having to keep
> multiple copies around to work around this problem just because cygwin
> wants to be special.

Frankly I'm surprised that ld ever finds a file named foo.lib when you
specify -lfoo.  Cygwin's gcc is a part of the gnu toolchain and tries to
follow the same file naming conventions that the gnu toolchain uses on
all platforms.  And in that convention libraries end in .a.  It is most
certainly not "just being special".  You're trying to put a square peg
in a round hole mixing -lfoo and files named .lib, and I'm not surprised
that it doesn't work in ways that make sense.

You might as well ask Microsoft why their linker's default search rules
won't ever find an import library named ".dll.a" and see what their
response is.

Brian

--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]