delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/06/09/00:58:51

X-Spam-Check-By: sourceware.org
Message-ID: <4488FFB5.6D34649@dessent.net>
Date: Thu, 08 Jun 2006 21:57:25 -0700
From: Brian Dessent <brian AT dessent DOT net>
X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: gcc -mno-cygwin still wants to link with cygwin libs
References: <Pine DOT LNX DOT 4 DOT 61 DOT 0606082353010 DOT 26665 AT interreality DOT org>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019