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 compiler and linker options


Guys,

Whilst I only signed up to this mailing list a couple of days ago, I can
naturally understand your frustration if this topic ( -mno-cygwin) is
dropping up over & over again and (apparently) being widely misunderstood.
What I don't accept is that you have any right to castigate people for not
understanding something which has clearly never been explained particularly
well.  Why am I arrogant enough to believe that it's never been explained
very well?  Well, that seems self-evident if there's such a widespread
misunderstanding of the topic.  Here's a link to the item that I read this
morning:-

http://www.mail-archive.com/cygwin@cygwin.com/msg49102.html

Note that it states:-
" Cygwin compilers normally create Cygwin executables, ie. executables that
require the Cygwin DLL to run. But they don't have to. The compilers that
come with the Cygwin package (gcc, g77 etc.) accept an "-mno-cygwin" switch.
This causes them to create executables that do *not* rely on the Cygwin DLL"

There's nothing at all there about cross-compilation and even if you read
the entire text, there's no indication that the writer himself had any
understanding that -mno-cygwin is applicable to cross-compilation.  In fact,
any developer would probably conclude from the above that -mno-cygwin is
some kind of switch that invokes static, rather than dynamic linking (thus
dispensing with the need for cygwin1.dll).  That was my first assumption and
I came to that conclusion because the writer's explanation was wholly
inadequate (which isn't actually MY fault).

In fact, that's precisely WHY I was asking if there was a more authoritative
resource.

John


----- Original Message ----- From: "Christopher Faylor" <cgf-use-the-mailinglist-please@cygwin.com>
To: <cygwin@cygwin.com>
Sent: 22 August 2008 15:19
Subject: Re: Cygwin compiler and linker options



On Fri, Aug 22, 2008 at 03:52:35PM +0100, Phil Betts wrote:
John Emmas wrote on Friday, August 22, 2008 1:54 PM::

Just doing some searches on the internet, there seems to be an awful
lot of misinformation / misunderstanding about what the various
Cygwin-gcc compiler and linker flags do.

For example, I saw one article that said that that flag -mno-cygwin
causes an executable to be generated which does *not* require
cygwin1.dll to be present on the host machine.  That doesn't seem to
be true (I've tried it).

If you link with cygwin DLLs, it is the DLLs that require cygwin1.dll, not the executable. If you compile with -mno-cygwin, do not link with any cygwin DLLs. You wouldn't link with a cygwin DLL if you were cross-compiling for Linux; the -mno-cygwin is essentially specifying a cross-compilation for a cygwin-free architecture.

Think of it like this:
 gcc -mvegan spaghetti.c -o meal -lparmesan
will not give you a vegan meal.


$ cat >hw.c <<'EOF'
#include <stdio.h>

int main (int argc, char **argv)
{
    puts ("Hello World");
    return 0;
}
EOF
$ gcc -mno-cygwin hw.c -o hw.exe
$ cygcheck ./hw.exe
.\hw.exe
 C:\WINDOWS\system32\msvcrt.dll
   C:\WINDOWS\system32\KERNEL32.dll
     C:\WINDOWS\system32\ntdll.dll
$ ./hw.exe
Hello World
$

I see no trace of cygwin1.dll in the cygcheck output.


I saw another article which said that if you
don't use the flag -mwindows, a DOS terminal will open every time you
launch your app.  That doesn't seem to be true either (at least, not
on my machine).

How are you launching it? If you're doing it from a prompt, there's no need to open another window. If you double-click on it in an Explorer window, you WILL get a DOS box unless you specified -mwindows. Try the above example and double click on it. You'll get a DOS box flash up momentarily. Recompile using -mwindows, and you won't.

Is there any resource available where I can find out some
(authoritative) information about what the various flags actually do?

From the examples you've given, it seems you've already found some authoritative information, but instead of doubting your ability to comprehend, you've chosen to doubt the words of others and criticize them in a public forum without providing any evidence to back up your assertions. Not only is that arrogant, but now YOUR misinformation / misunderstanding is out there to cause confusion for others.

It would be nice if the cygwin-specific options were documented in the
gcc info file, but they don't appear to be.  Don't expect -mno-cygwin
to appear there soon either, because my understanding is that the
-mno-cygwin option will be removed soon because of the surprising
number of people who can't seem to grasp the concept of no-cygwin.

Phil is 100% correct here. It's heartening to see someone so thoroughly getting it after having to so frequently deal with the misconceptions about -mno-cygwin. Confusion about -mwindows is new though.

I'm counting the days until -mno-cygwin disappears.  It is a blight that
must be expunged.  I know that as soon as it is gone there will be a
general wail from people who use it but it really should never have been
implemented.
--
Christopher Faylor spammer? -> aaaspam@sourceware.org
Cygwin Co-Project Leader
Netapp, Inc.

--
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/



--
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]