This is the mail archive of the cygwin@sourceware.cygnus.com 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]

Re: Standalone linking with minimalist



On Wed, 21 May 1997, Justin B. Harvey wrote:

> What the heck am I doing wrong?  When I compile programs and want them to
> run by themselves without cygwin.dll I do a:
> 
> gcc hello.c -o hello.exe -L/src/ming/lib -lcrtdll -lmingw32 -dll  
> 

If you are building an exe(hello.exe) you don't need the '-dll' option.
Otherwise everything else looks fine.

> Then I can export this program to other machines and run it, but....when I
> try to compile more complex programs I get errors like this:
> 
> (c:\src\tf-35b4\src\tf.exe 1736) In cygwin_except_handler
> (c:\src\tf-35b4\src\tf.exe 1736) Exception trapped!
> (c:\src\tf-35b4\src\tf.exe 1736) exception C0000005 at 776415CE
> (c:\src\tf-35b4\src\tf.exe 1736) exception: ax FCC4FCA8 bx 0 cx 1D dx
> FFFFFFFF
> (c:\src\tf-35b4\src\tf.exe 1736) exception: si FCC4FCA8 di 6A78ECE0 bp
> 242F3AC sp242F3A4
> (c:\src\tf-35b4\src\tf.exe 1736) exception is: STATUS_ACCESS_VIOLATION
> (c:\src\tf-35b4\src\tf.exe 1736) Stack trace:
> (c:\src\tf-35b4\src\tf.exe 1736) frame 0: sp = 0x242F1D8, pc = 0x1000CEC2
> (c:\src\tf-35b4\src\tf.exe 1736) frame 1: sp = 0x242F1F4, pc = 0x77F94512
> (c:\src\tf-35b4\src\tf.exe 1736) frame 2: sp = 0x242F218, pc = 0x77F88EEB
> (c:\src\tf-35b4\src\tf.exe 1736) frame 3: sp = 0x242F2A4, pc = 0x77F76266
> (c:\src\tf-35b4\src\tf.exe 1736) frame 4: sp = 0x242F3AC, pc = 0x7763C15C
> (c:\src\tf-35b4\src\tf.exe 1736) frame 5: sp = 0x242F3C8, pc = 0x419112
> (c:\src\tf-35b4\src\tf.exe 1736) frame 6: sp = 0x242F3E0, pc = 0x40D442
> (c:\src\tf-35b4\src\tf.exe 1736) frame 7: sp = 0x242F3F4, pc = 0x40D2EC
> (c:\src\tf-35b4\src\tf.exe 1736) frame 8: sp = 0x242F43C, pc = 0x1000C102
> (c:\src\tf-35b4\src\tf.exe 1736) frame 9: sp = 0x242FF94, pc = 0x1000C113
> (c:\src\tf-35b4\src\tf.exe 1736) frame 10: sp = 0x242FFA0, pc = 0x41C40D
> (c:\src\tf-35b4\src\tf.exe 1736) frame 11: sp = 0x242FFB0, pc = 0x40103B
> (c:\src\tf-35b4\src\tf.exe 1736) frame 12: sp = 0x242FFC0, pc = 0x77F1B304
> (c:\src\tf-35b4\src\tf.exe 1736) frame 13: sp = 0x242FFF0, pc = 0x0
> (c:\src\tf-35b4\src\tf.exe 1736) End of stack trace
> bash$
> 
> What is the correct syntax on a linkline for building standalone
> executables without cygwin.dll?  
> 

Your syntax above was correct except for the -dll option that you added.
The syntax is the same as building with cygwin32 except you need to
specify the path to the mingw32 librarys in the environment variable
LIBRARY_PATH or on the command line with -L.  When using mingw32 make sure
that gcc does not look in the directory that containes libcygwin32.a.  One
way to do this is locate the directory with a find utility, then remove
the path to that directory from the LIBRARY_PATH environment variable.
This way gcc and ld do not link the cygwin32.dll library to your
application.

In my environment when I use gcc and mingw32 I have my LIBRARY_PATH set to
/cygnus/mingw32/lib:/cygnus/win32/lib

where /cygnus/mingw32 contains all the Minimalist GNU Win32 files.  I
also placed all the win32 files in the win32 directory.  This way it is
easier to keep the cygwin and the stand alone libraries separate.

It is obvious from your exception that the cygwin32 DLL is linked to your
program.

Hope this helps.

Eric Britten


> Frustrated,
> 
> Justin
> --
> Justin B. Harvey
> jbharvey@gte.net
> http://home1.gte.net/jbharvey
> -
> For help on using this list (especially unsubscribing), send a message to
> "gnu-win32-request@cygnus.com" with one line of text: "help".
> 

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


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