C compiler for PC (tested first example)
John Gianni
john@cadence.com
Fri Oct 1 00:00:00 GMT 1999
A friend asked what C compiler to use on the PC. I never compiled a C
program in my life for the PC, but, I looked it up. I was amazed at
how _hard_ it was to find a pre-compiled Gcc for the Win95 PC. (The web
page referenced below is about as confusing as Kosovo).
So, I gave up, in the interests of time, on getting her Gcc for the PC.
Here is the method we used which appears to be a good 1st C program walk-thru.
If you know of a simple way to put GCC on a Win9 PC (and not at the top
level either), please advise john@cadence.com
Thanks,
Enjoy,
John Gianni
****************************************************************************
How to compile your first ANSI C program on the Win95 PC in 10 quick steps.
8/99 John Gianni Version 1.02 Tested only on Win95 & Win98
Please send improvements to "john@cadence.com" so everyone benefits.
****************************************************************************
============================================================================
1. Search on the Internet for any suitable ANSI C compiler, e.g., use:
http://www.dogpile.com or http://www.dejanews.com
See Appendix A for a list of available C compilers for the Win95/98 PC.
============================================================================
2. Arbitrarily choose one of the Win95 compilers to download & install.
For example, I arbitrarily chose "Miracle C" as my first test.
[Start][Run] http://www.ncf.carleton.ca/%7Ebg283/
Press the "Download" button to obtain the 246Kbyte winzip archive;
save into any temporary directory, e.g., c:\tmp\download\miracle.zip
============================================================================
3. Create a directory where you plan to install the C-compiler software:
Note: Use any logical location for the Miracle C binary directory, e.g.,
[Start][Run]command
mkdir c:\bin
mkdir c:\bin\compiler
mkdir c:\bin\compiler\mcw
Note: Choose any directory tree you like; however, bear in mind, your
life will be much easier if your dir names are <= 8 characters.
============================================================================
4. Unpack the Win95 ANSI C shareware compiler into your final destination.
Choose the same destination as in the previous step, e.g., unpack into
c:\bin\compiler\mcw
Note: Use any desired decompression utility, e.g., WinZip, Pkunzip, etc.
============================================================================
5. Set up the MCW compiler paths to point to your destination location, e.g.:
Double-click on c:\bin\compiler\mcw.exe and set these three paths:
[Options][Compiler...]
Include Path = c:\bin\compiler\mcw\include
Base Path = c:\bin\compiler\mcw
---------------------------------------------------------
[Options][Linker...]
Library Path = c:\bin\compiler\mcw
---------------------------------------------------------
Note: You must use the DOS-style 8+3 directory-name convention here!
Note: The action above automatically modifies your c:\win.ini file, e.g.:
[MCW]
include=c:\bin\compiler\mcw\include
base=c:\bin\compiler\mcw
libpath=c:\bin\compiler\mcw
============================================================================
6. Now the fun starts! Write your first test program on the Win95 PC.
(Traditionally, you would choose a very simple hello-world program.)
Double-click on the c:\bin\compile\mcw.exe executable to start it up.
In the MCW program, press [File][New] (this pops up an mcw-editor window).
Type the hello.c program below into the mcw editor window:
----< cut here for hello.c >-----
/*
This is my first C src program to be compiled on the Win95/98/NT PC.
<Your Name Here> version 1.00 <current date here>
*/
#include <stdio.h>
main()
{
printf("Hello world.\n");
return 0;
}
----< cut here for hello.c >-----
In MCW, press [File][Save As...]c:\tmp\hello.c
This saves your first C program to disk.
============================================================================
7. Compile this first hello.c test program into an object module:
In the MCW program (make sure your editor window is the active window),
press [Run][Compile].
Note: This creates the hello.obj object module.
And, it creates hello.src (what is this?).
============================================================================
8. Link object modules for this first hello.c test:
In the MCW program (make sure your editor window is the active window),
press [Run][Build]. You should see "Build completed."
Note: This builds the c:\tmp\hello.exe executable.
And, it creates hello.map (what is this?).
Note: If you see the message "Cannot compile output window", then you
probably didn't select the editor window to make it the active
window before running the build command.
============================================================================
9. Execute your new 'hello.exe' executable for this first hello.c test:
Test from MCW:
In the MCW program, press [Run][Execute...].
Press [Run] to execute "c:\tmp\hello.exe".
Up should pop a window with "Hello world" in it.
(If the window goes away too fast -- see Appendix B below.)
Viola! Your first C program, written, compiled, & executed on the PC.
============================================================================
10. Test your new 'hello.exe' executable using a variety of methods:
a) Test from the Start-Menu interface:
b) Test from the DOS-Emulation interface:
c) Test from the "My Computer" explorer interface:
------------------------------------------------------------------------
A) Test from the Start-Menu command interpreter window:
[Start][Run]c:\tmp\hello.exe
Up should pop a window with "Hello world" in it.
------------------------------------------------------------------------
B) Test from the DOS-Emulation interface:
[Start][Run]command
At the DOS prompt, type: c:\tmp\hello.exe
Up should pop a window with "Hello world" in it.
------------------------------------------------------------------------
C) Test from the "My Computer" explorer interface:
From "My Computer", double-click on c:\tmp\hello.c
Up should pop a window with "Hello world" in it.
------------------------------------------------------------------------
============================================================================
Appendix A:
My 8/99 search found these potentially promising C compilers for the PC:
Please let me know of any better, or simpler C compilers for the Win95 PC.
(I was hoping to use the free GNU CC, but, can't find a simple installation.)
The official development site for GCC:
http://egcs.cygnus.com/
The official GNU Gcc distribution site:
http://gnudist.gnu.org/software/gcc/gcc.html
http://gnudist.gnu.org/software/gcc/faq.html
The official Windows-based GCC site:
http://sourceware.cygnus.com/cygwin/
Miracle C Compiler (MCW) shareware:
http://www.ncf.carleton.ca/%7Ebg283/
Univ. of Brooklyn easy-to-install GCC distribution:
http://www.sci.brooklyn.cuny.edu/~gurwitz/cis16/gcc.html
Princeton University ANSI C compiler (lcc):
http://www.cs.princeton.edu/software/lcc/index.html
GNU cc compiler for the Win95 PC:
http://www.mta.ca/~rford/gnucc/
DevC and C++ compiler for Win95:
http://www.bloodshed.nu/devc.html
DJGPP development environment (Gcc compiler & RHIDE debugger):
http://www.delorie.com/
http://cs.mta.ca/~robert/correspondence/cs1711/compiler.html
Pre-compiled GCC Win95 binaries:
http://www.xraylith.wisc.edu/~khan/software/gnu-win32/
Small C colmpiler (compiles C to Assembly Language):
http://www.softseek.com/Programming/C/D_23540_index.html
Interactive C interpreter for Win95:
http://www.anarchos.com/eic/
etc.
============================================================================
Appendix B:
If, when you run your C program, the DOS window dissappears too quickly,
then your default PIF file is probably set to "Close on exit".
Simply right-click on your default PIF file; select "Properties";
then select the "Program" tab; and un-check the "Close on exit" box.
This will keep the DOS window open even after the program finishes
(so you can see the result).
Here is the location of the default program information file for the PC:
Win95: c:\win95\command.pif (or c:\windows\command.pif)
Win98: c:\win95\command.pif (or c:\windows\command.pif)
WinNT: c:\winnt\_default.pif (or c:\windows\_default.pif)
Win3.1: c:\windows\_default.pif (or c:\windows\_default.pif)
Note: If all you see is a DOS icon & the word "command" (without an
extension), that's probably your PIF file. If you want to see the PIF
extension, you must edit your registry ([Start][Run]regedit) to change:
FROM: HKCR\piffile\NeverShowExt=""
TO: HKCR\piffile\_NeverShowExt=""
Many people do not realize Windows lies to you for certain files
(pif, lnk, etc.) unless this subkey is changed.
============================================================================
Good luck. Note that there are some simple examples in the MCW example
directory. It is good practice to compile and run those programs before
writing & compiling your next C program.
============================================================================
BTW, if you actually use the cc program above -- it's shareware so register
as required.
============================================================================
****************************************************************************
End of:
How to compile your first ANSI C program on the Win95 PC in 10 quick steps.
****************************************************************************
More information about the Gcc-help
mailing list