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


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
-- 
This email has been scanned by Ascribe PLC using Microsoft Antigen for Exchange.

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