Compiling game for class (not a homework request)

Hi all, I've been assigned some homework (I know but keep reading) which requires me to alter a little game written by my instructor. unfortunately I cant compile it to begin with! I'm running OS X 10.4.11 can anyone give me any insight into why those gcc commands might not work?????


It includes the following items
http://i5.nyu.edu/~mm64/book/src/term/term.h
http://i5.nyu.edu/~mm64/book/src/terminal/terminal.h
http://i5.nyu.edu/~mm64/book/src/terminal/terminal.C
http://i5.nyu.edu/~mm64/x52.9265/src/rabbit.h
http://i5.nyu.edu/~mm64/x52.9265/src/rabbit.c
http://i5.nyu.edu/~mm64/x52.9265/src/wolf.h
http://i5.nyu.edu/~mm64/x52.9265/src/wolf.c
http://i5.nyu.edu/~mm64/x52.9265/src/main.C


Its from this page:
http://i5.nyu.edu/~mm64/x52.9265/#homework65




Run the game consisting of the following nine files, but don’t hand it in. To compile term.h, and term.c, see the Homework 1.7.3a instructions for Unix and Bloodshed.

1. term.h and term.c (in the language C). See Chapter 1, pp. 85–89.
2. terminal.h and terminal.C. See Chapter 2, pp. 157–163.
3. rabbit.h and rabbit.C. See Chapter 2, pp. 192–200.
4. wolf.h and wolf.C
5. main.C



Instructions for compiling
1$ gcc -I. -DUNIX= -c term.c //Create the object fileterm.o.
2$ ls -l term.o // minus lowercase L
3$ g++ -I. -o ̃/bin/tester main.C term.o -lcurses
4$ ls -l ̃/bin/tester
5$ tester // Run it; but first makesureyour terminal is set tovt100,bitansi.

It would help if you posted the error messages you get when you compile and line the program.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Sorry...  I've gotten so many errors it kind of seems pointless.  but heres my latest attemp







Last login: Sat Apr 18 22:28:10 on console
Welcome to Darwin!
me-lastnames-computer:~ melastname$ ls
3point12a               Movies                  game001
Desktop                 Music                   game002
Documents               Pictures                game003
Estate Catalog jic      Public                  iomaniphw
FXpansion               Sites
Library                 downloads
me-lastnames-computer:~ melastname$ cd Desktop
me-lastnames-computer:~/Desktop melastname$ cd game\ downloade
-bash: cd: game downloade: No such file or directory
me-lastnames-computer:~/Desktop melastname$ cd game\ download
me-lastnames-computer:~/Desktop/game download melastname$ gcc -I. -DUNIX= -c term.cpp -D_WIDEC_H=
me-lastnames-computer:~/Desktop/game download melastname$ setenv TERM vt100
-bash: setenv: command not found
me-lastnames-computer:~/Desktop/game download melastname$ export TERM=vt100 
me-lastnames-computer:~/Desktop/game download melastname$ 
me-lastnames-computer:~/Desktop/game download melastname$ g++ -I. -o  \314\203~/bin/tester main.cpp term.o -lcurses  -include term.h term.o wolf.h.gch wolf.h terminal.cpp rabbit.h term.h.gch termoo.h.gch term.cpp rabbit.h.gch wolf.cpp terminal.h main.cpp rabbit.cpp
wolf.h:1: fatal error: can't create precompiled header ̃~/bin/tester: No such file or directory
compilation terminated.
rabbit.h:1: fatal error: can't create precompiled header ̃~/bin/tester: No such file or directory
compilation terminated.
terminal.h:1: fatal error: can't create precompiled header ̃~/bin/tester: No such file or directory
compilation terminated.
me-lastnames-computer:~/Desktop/game download melastname$ g++ -I. -o  \314\203/bin/tester main.cpp term.o -lcurses  -include term.h term.o wolf.h.gch wolf.h terminal.cpp rabbit.h term.h.gch termoo.h.gch term.cpp rabbit.h.gch wolf.cpp terminal.h main.cpp rabbit.cpp
wolf.h:1: fatal error: can't create precompiled header ̃/bin/tester: No such file or directory
compilation terminated.
rabbit.h:1: fatal error: can't create precompiled header ̃/bin/tester: No such file or directory
compilation terminated.
terminal.h:1: fatal error: can't create precompiled header ̃/bin/tester: No such file or directory
compilation terminated.
me-lastnames-computer:~/Desktop/game download melastname$ 
me-lastnames-computer:~/Desktop/game download melastname$ g++ -I. -o  \314\203~/bin/tester main.cpp term.o -lcurses -include term.h term.o wolf.h.gch wolf.h terminal.cpp rabbit.h term.h.gch termoo.h.gch term.cpp rabbit.h.gch wolf.cpp terminal.h main.cpp rabbit.cpp
wolf.h:1: fatal error: can't create precompiled header ̃~/bin/tester: No such file or directory
compilation terminated.
rabbit.h:1: fatal error: can't create precompiled header ̃~/bin/tester: No such file or directory
compilation terminated.
terminal.h:1: fatal error: can't create precompiled header ̃~/bin/tester: No such file or directory
compilation terminated.
me-lastnames-computer:~/Desktop/game download melastname$ g++ -I. -o ~/bin/tester main.cpp term.o -lcurses -include term.h term.o wolf.h.gch wolf.h terminal.cpp rabbit.h term.h.gch termoo.h.gch term.cpp rabbit.h.gch wolf.cpp terminal.h main.cpp rabbit.cpp
wolf.h:1: fatal error: can't create precompiled header /Users/melastname/bin/tester: No such file or directory
compilation terminated.
rabbit.h:1: fatal error: can't create precompiled header /Users/melastname/bin/tester: No such file or directory
compilation terminated.
terminal.h:1: fatal error: can't create precompiled header /Users/melastname/bin/tester: No such file or directory
compilation terminated.
me-lastnames-computer:~/Desktop/game download melastname$ g++ -I. -o ~/bin/tester main.cpp term.o -lcurses -include term.h term.o wolf.h.gch wolf.h terminal.cpp rabbit.h term.h.gch termoo.h.gch term.cpp rabbit.h.gch wolf.cpp terminal.h main.cpp rabbit.cpp
wolf.h:1: fatal error: can't create precompiled header /Users/melastname/bin/tester: Is a directory
compilation terminated.
rabbit.h:1: fatal error: can't create precompiled header /Users/melastname/bin/tester: Is a directory
compilation terminated.
terminal.h:1: fatal error: can't create precompiled header /Users/melastname/bin/tester: Is a directory
compilation terminated.
me-lastnames-computer:~/Desktop/game download melastname$ 
You should probably start building yourself a Makefile to automate the build process.

You have funky characters in your build string: "g++ -I. -o \314\203~/bin/tester"

You are trying to do too many things at once. Try this one step and see if it works:

g++ -I. -o main.o main.cpp

then...

g++ -I. -oterminal.o terminal.cpp

do that for every cpp file.

Once that is done, link all of the object files and executables:

g++ -o tester main.o terminal.o ... -lcurses Note the ellipses -- you need to replace my ellipses with all object files you built in the previous steps.
Topic archived. No new replies allowed.