[EMAIL PROTECTED] 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/