Subject: Re: static linking?
From: [email-masked]

13 Feb 1998 01:17:34 -0800
Message-ID: <[email-masked]>
To: [email-masked]
Cc: [email-masked]

> ... how
> does one create a statically-linked executable with gcc/g++/ld?
> i've tried -static with gcc and -Bstatic with ld, and neither seem
> to work.  linking in crt0.o, libcygwin.a, etc. doesn't do the
> job either.  what i want is to run an executable compiled under
> gnu-win32 run on a machine without gnu-win32.  i've read the FAQ,
> searched the mailing list archives and altavista without luck.

I believe that you have to create a static library from the cygwin routines.
Look where cygwin.dll is built and instead of building a DLL there, build
a standard library (a .a file).  Then, link this against your program.

Note that this may not work because there are some things that the OS
does for DLLs that will not be done.  You may be able to fake this by
calling Dllmain() directly when your program starts up.  There are some
shared data regions within cygwin.dll that will no longer be shared if
you make it into a static library, and this may cause some problems...

You should be able to achieve the same effect by putting cygwin.dll
on the target machine along with your executable.  The entire source
tree need not be installed on the target machine.  There may be some
registry entries you want to make to support the cygwin execution
environment, and/or some environment variables.  These would be needed
regardless of whether cygwin was linked as a DLL or statically linked.

marcus hall
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".