This is the mail archive of the cygwin 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]
Other format: [Raw text]

Re: CygWin + gcc to build Windows application written in C.


Piero Silvestri wrote:

> - I'm looking for some documentation about -mno-cygwin and -mwindows
> options, which I can't find neither in the gcc on-line manual, nor in the
> gcc man pages, nor in the CygWin manual. Where they come from? Using the
> first makes the compiler complain about a missing crt2.o (?), the last seems
> to be ignored.

-mno-cygwin essentially turns gcc into the gcc provided by mingw.org. 
Read the docs/wiki/faq/etc at that site for more information.  Note that
when you use gcc -mno-cygwin your search paths will be modified so that
no Cygwin libraries/headers will be found, instead the mingw ones will
be searched (/usr/include/mingw, /usr/lib/mingw).  Essentially this is
just a shortcut for compiling with the mingw toolchain under Cygwin - do
not get confused and think that this somehow lets you use Cygwin library
functions in any shape or form.  If you use mingw or -mno-cygwin, you
are essentially programming directly at the win32 API and the MSVCRT,
you have no unix emulation at all other than what is provided by the
microsoft C library.

-mwindows is a linker option that is short for "--subsystem windows",
just as -mconsole is short for "--subsystem console".  You can read more
about ld options at
<http://sourceware.org/binutils/docs-2.16/ld/Options.html>.  The actual
meaning of this setting is documented by the Microsoft linker's
/SUBSYSTEM option:
<http://msdn.microsoft.com/library/en-us/vccore/html/_core_.2f.SUBSYSTEM.asp>.

This switch probably does not mean what you think it means.  It does not
mean "make a windows binary."  Nor does it mean "allow the application
to have a GUI."  All it does is tell the system not to allocate a
console for the program when it's started.

> - I have a mysterious linker error (undefined reference to __imp___iob); I
> searched the web and found some hints about using MinGW under Cygwin, but
> nothing clear or certain; above all, only questions but not answers...

That probably means that you're trying to mix and match cygwin-compiled
and mingw-compiled objects into a final .exe.  That's not going to
work.  Cygwin and mingw use completely separate C runtime environments. 
They should be considered different platforms completely.  You can't
expect to link a Cygwin library into a mingw .exe for example.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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