www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/09/20/07:15:00

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: |||||||||| DJGPP Compiler--Help! ||||||||||
Date: Thu, 19 Sep 1996 23:27:03 -0700
Organization: Three pounds of chaos and a pinch of salt
Lines: 84
Message-ID: <32423937.5759@cs.com>
References: <3241dd39 DOT 3872974 AT news DOT sprynet DOT com>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp202.cs.com
Mime-Version: 1.0
To: Louis Cappitelli <lcappite AT sprynet DOT com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Louis Cappitelli wrote:
> 
> Okay. I made my c++ file. Now what do I do. I want to compile and run
> it, but I don't know how and what file format to save my prog as in my
> text editor so djgpp can compile it. I know u'll say "it's in the
> FAQs", but so far, they're of no help.

Actually, this is a much more basic question than the FAQ is designed
to cover.  :)

First, you don't require any special format for your program files.  All
they have to be is plain text, which can be produced by any editor.

Second, your program files must have _extensions_ which denote what type
of program they are.  Some common extensions:

.c	<-- C programs
.C	<-- C++ programs 	NOTE:  On normal DOS systems, which are
				case-insensitive, this will NOT work
				properly.
.cc	<-- also C++ programs (most common)
.cpp	<-- also C++ programs (popular with Borland and Turbo C++ users)
.S	<-- assembly source
.o	<-- object code emitted by the compiler.  You can't run this
	    until it is linked with the runtime libraries.
.a	<-- the libraries which contain the actual code for all of the
	    C and C++ functions that you use.  Linked with your object
	    code at compilation

There are many more, but that's a start.

Third, DJGPP is a command-line compiler.  If you want a graphical IDE
environment, you can try out RHIDE, available from the same place you
got DJGPP.  WARNING:  RHIDE is in beta, so there are many bugs!

Fourth, here's a basic command to compile your program.  I will assume
that it's called "myprog.c".

   gcc -o myprog myprog.c

'gcc' is the main interface program for the compiler, and will do all
the work for you.  The '-o myprog' in that command tells the compiler
to produce the image file 'myprog' (which is useful for debugging),
and an executable file 'myprog.exe', which you can then run.  If you
don't include this, the default filenames are 'a.out' and 'a.exe',
which are a pain.  ;)

Here's a more complex version of the above:

   gcc -Wall -g -O -o myprog.exe myprog.c mystuff.c

Commands:
  -Wall		Turns on many options for the compiler to warn you
		when you try to compile unsafe code.  *All* beginners
		should use this - it can help a lot!

  -g		Makes the compiler produce information that will allow
		your program to be run by the interactive debuggers
		that come with DJGPP.  See the docs for 'gdb' and 'fsdb'
		for more on this, as well as the FAQ (section 12)

  -O		Makes the compiler _optimize_ your code for speed and
		performance.  Also enables some error detection that
		is not available without optimization.

Note that you can compile multiple source files _of the same program_
at the same time; gcc is more than smart enough to know what to do.

For anything more complex than this, I really recommend that you find
a good C programming book, or a good friend who knows the language.
Bootstrapping yourself into C is a long, tough haul, and can really
get you into some seriously bad programming habits.

Hope this helps!

-- 
--------------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I    |         fighteer AT cs DOT com          
|
| Plan:  To find ANYONE willing to   |    http://www.cs.com/fighteer    
|
| play Descent 2 on DWANGO!          |  Tagline: <this space for rent>  
|
--------------------------------------------------------------------------

- Raw text -


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