Date: Wed, 25 Aug 1999 12:51:22 +0200 From: Hans-Bernhard Broeker Message-Id: <199908251051.MAA31093@acp3bf.physik.rwth-aachen.de> To: anne DOT hawson AT virgin DOT net (Anne Hawson) Cc: djgpp AT delorie DOT com Subject: Re: I can't compile with the -O2 switch. Newsgroups: comp.os.msdos.djgpp Organization: RWTH Aachen, III. physikalisches Institut B X-Newsreader: TIN [version 1.2 PL2] Reply-To: djgpp AT delorie DOT com In article <7purvn$j7h$1 AT nclient11-gui DOT server DOT virgin DOT net> you wrote: > I wanted to compile C++ code into an executable with optimisations. > In this case, it is a tiny program called "keypress.cpp" > (pasted at the end of this message). > It compiles fine with - > > gxx -o keypress.exe keypress.cpp > but complains with - > > gxx -O2 keypress.exe keypress.cpp That's because there's a major error in that command line. It ought to have been gxx -O2 -o keypress.exe keypress.cpp The '-O2' is one option, and '-o keypress.exe' is another one. These two have almost nothing to do with each other: '-O2' means: optimize the code '-o keypress.exe' means: call the resulting program 'keypress.exe', instead of the default 'a.exe' (and 'a.out'). Your command line is interpreted as: compile keypress.c (to keypress.o) then link keypress.exe and keypress.o, forming the new program 'a.exe' Obviously, that can't work, as keypress.exe is not usable as a part of a program, it's a full program on its own. -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.