delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/12/05/13:28:05

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <3C0E669D.1090408@ece.gatech.edu>
Date: Wed, 05 Dec 2001 13:25:33 -0500
From: Charles Wilson <cwilson AT ece DOT gatech DOT edu>
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.4) Gecko/20010914
X-Accept-Language: en-us
MIME-Version: 1.0
To: T-FERNANDEZ AT dassault-data-services DOT fr
CC: cygwin AT cygwin DOT com
Subject: Re: GCC : -static option does not generate statically linked executable
References: <OF49EA1364 DOT 67B4844C-ONC1256B19 DOT 0055088C AT dds DOT fr>
X-Virus-Scanned: by amavisd-milter (http://amavis.org/)

T-FERNANDEZ AT dassault-data-services DOT fr wrote:

> Hi,
> 
> I am trying to generate an executable, using "gcc -static" option.
> The generated file is dynamically linked! As if the "-static" option was
> simply ignored.
> 
> The output of "cygcheck" is as follows :
> 
> Error: could not find libX11.dll
>   C:\cygwin\bin\cygwin1.dll
>     C:\WINNT\System32\KERNEL32.dll
>       C:\WINNT\System32\ntdll.dll
>   C:\cygwin\bin\cygtcl80.dll
>     C:\WINNT\System32\USER32.dll
>       C:\WINNT\System32\GDI32.dll
>         C:\WINNT\System32\ADVAPI32.dll
>           C:\WINNT\System32\RPCRT4.dll
>   C:\cygwin\bin\cygtk80.dll
>     C:\WINNT\System32\COMDLG32.DLL
>       C:\WINNT\System32\SHELL32.dll
>         C:\WINNT\System32\COMCTL32.dll
> 
> One can see that the X11 DLL library is not found : however, I use the
> -static option of gcc, before the -lX11 stuff, as mentioned in the
> documentation.
> I expect the compiler to link against libX11.a, so what happens?
> 
> Any idea would be greatly appreciated,


-static will cause the linker to link against a static lib IF POSSIBLE. 
  However, it really just means "hunt for '.a' instead of '.dll.a' or 
'.dll'"

.dll.a == import lib for a dll
.dll   == the linker has a limited ability to link directly to a dll 
*without* using an import lib.
.a     == static lib (mostly *)

(*) The problem: many packages -- including X -- name their *import* 
libs using the .a suffix.  So, when you specify -static, the linker 
diligently links against the .a file == an import lib == and you get a 
dynamically linked executable.

When this sort of behavior happens, it's usually becuase there IS no 
static library at all -- you CAN'T link statically.  (The X libraries 
are a good example; cygwin-xfree project does NOT provide static libs.)

Also, note that you can't link a cygwin program *fully* statically -- at 
minimum, it will require cygwin1.dll...

As far as your particular "can't find libX11.dll" problem -- add 
/usr/X11R6/bin to your system PATH.

--Chuck




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.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