Subject: RE: compilling probs
To: None <amcolomb@students.wisc.edu>
From: Steve Revilak <revilak@umbsky.cc.umb.edu>
List: port-mac68k
Date: 08/09/1999 14:50:13
Just wanted to see if I could compile a simple console program and
to my surprise I was able to. The only problem is every time I execute it,
nothing happens. There should be some output to the console, but non shows
up. To compile the app I use "g++ -Wall test.cc -o test".
I've generally used "gcc" to compile, but that line looks okay to me.
The catch is that if there are no errors and nothing to warn you about,
you *won't* see any output. One idea - stick a few gremlins in your
sourcecode. Misspell a few functions, add a couple extra opening braces,
a few undefined symbols, etc.
/I used to use
/makefile on a Unix box a school, but for the life of me I can't remember
/how to write the nakefile and the man pages only refer to a Tutorial for
/that. Any ideas?
Here's an HTML manual for make:
http://www.lns.cornell.edu/public/COMP/info/make/make_toc.html
You can also download a copy from http://www.gnu.org. Or, try "info
make". Or, in emacs, try "M-x info" ahen following the reference to
make. (Emacs info reader is a little friendlier than the command line
equivalent).
the general makefile format is:
<target>: <depencecny list>
<commands>
For your example above (I'll add another source file though to try
making it a better example), Given 3 files -- test.c, otherfile.c, and
test.h --you might have something like (here, I'm not making use of
implicit rules).
CC = gcc # variable for the name of the compiler
CFLAGS = -g -Wall # flags for the compiler. Warnings and syms.
test : test.c otherfile.c
$(CC) $(CFLAGS) test.o otherfile.o -o test
test.o : test.c test.h
$(CC) $(CFLAGS) -c test.c
otherfile.o : otherfile.c test.h
$(CC) $(CFLAGS) -c otherfile.c
.PHONY: clean
clean:
rm *.o
(.PHONY designates the target "clean" as one that doesn't have any file
dependencies -- all it does is blow up up old object code. But the
phony spec keeps clean from breaking if you you were to ever have a file
in that directory named "clean").
gcc -M will generate a ready-made dependency list for you. Something
like:
gcc -M otherfile.c test.c -o test