From 1fd5e000ace55b323124c7e556a7a864b972a5c4 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 17 Feb 2000 19:38:33 +0000 Subject: import winsup-2000-02-17 snapshot --- winsup/doc/gcc.sgml | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 winsup/doc/gcc.sgml (limited to 'winsup/doc/gcc.sgml') diff --git a/winsup/doc/gcc.sgml b/winsup/doc/gcc.sgml new file mode 100644 index 000000000..d13bba116 --- /dev/null +++ b/winsup/doc/gcc.sgml @@ -0,0 +1,78 @@ +Using GCC with Cygwin + +Console Mode Applications + +Use gcc to compile, just like under UNIX. +Refer to the GCC User's Guide for information on standard usage and +options. Here's a simple example: + + +Building Hello World with GCC + +C:\cygnus\> gcc hello.c -o hello.exe +C:\cygnus\> hello.exe +Hello, World + +C:\cygnus\> + + + + + +GUI Mode Applications + +Cygwin allows you to build programs with full access to the +standard Windows 32-bit API, including the GUI functions as defined in +any Microsoft or off-the-shelf publication. However, the process of +building those applications is slightly different, as you'll be using +the GNU tools instead of the Microsoft tools. + +For the most part, your sources won't need to change at all. +However, you should remove all __export attributes from functions +and replace them like this: + + +int foo (int) __attribute__ ((__dllexport__)); + +int +foo (int i) + + +For most cases, you can just remove the __export and leave it at +that. For convenience sake, you might want to include the following +code snippet when compiling GUI programs. If you don't, you will want +to add "-e _mainCRTStartup" to your link line in your Makefile. + + +#ifdef __CYGWIN__ +WinMainCRTStartup() { mainCRTStartup(); } +#endif + + +The Makefile is similar to any other UNIX-like Makefile, +and like any other Cygwin makefile. The only difference is that you use +gcc -mwindows to link your program into a GUI +application instead of a command-line application. Here's an example: + + +myapp.exe : myapp.o myapp.res + gcc -mwindows myapp.o myapp.res -o $@ + +myapp.res : myapp.rc resource.h + windres $< -O coff -o $@ + + +Note the use of windres to compile the +Windows resources into a COFF-format .res file. +That will include all the bitmaps, icons, and other resources you +need, into one handy object file. Normally, if you omitted the "-O +coff" it would create a Windows .res format file, +but we can only link COFF objects. So, we tell +windres to produce a COFF object, but for +compatibility with the many examples that assume your linker can +handle Windows resource files directly, we maintain the +.res naming convention. For more information on +windres, consult the Binutils manual. + + + -- cgit v1.2.3