delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/08/22/10:55:45

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
Subject: RE: Cygwin compiler and linker options
Date: Fri, 22 Aug 2008 15:52:35 +0100
Message-ID: <5E25AF06EFB9EA4A87C19BC98F5C8753014F88E0@core-email.int.ascribe.com>
In-Reply-To: <002f01c90456$1f080e50$4001a8c0@mycomputer>
References: <4126b3450808220352y12a25fddi444e3df3e1cb590a AT mail DOT gmail DOT com> <002f01c90456$1f080e50$4001a8c0 AT mycomputer>
From: "Phil Betts" <Phil DOT Betts AT ascribe DOT com>
To: <cygwin AT cygwin DOT com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id m7MEtiJs032279

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/


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019