Makefile

C++Fun's Avatar, Join Date: Aug 2008
Newbie Member
Hi, I need some help with writing makefile. I tried to build undermentioned code(in OS SOLARIS), but it doesnt work. Heads files are included many times in project, so i used ${HEAD} instead of writing each head file. Thanks for any help
Code:
///////////////////////////////////////////////////////////////////////
OBJ:  AI.o Main.o UzivRozhrani.o Zasobnik.o KontrolaVyhry.o 
HEAD: AI.h UzivRozhrani.h Zasobnik.h KontrolaVyhry.h 
SRC:  AI.cpp Main.cpp UzivRozhrani.cpp Zasobnik.cpp KontrolaVyhry.cpp

CC = g++
CFLAGS=-Wall -Wno-long-long -pedantic
piskvorky: ${OBJ}
	${CC} ${OBJ} -o piskvorky

AI.o: AI.cpp ${HEAD} 
	$(CC) $(CFLAGS) AI.cpp
Main.o: Main.cpp ${HEAD}
	$(CC) $(CFLAGS) Main.cpp
UzivRozhrani.o: UzivRozhrani.cpp  ${HEAD}
	$(CC) $(CFLAGS) UzivRozhrani.cpp
Zasobnik.o: Zasobnik.cpp ${HEAD}
	$(CC) $(CFLAGS) Zasobnik.cpp
KontrolaVyhry.o: KontrolaVyhry.cpp ${HEAD}
	$(CC) $(CFLAGS) KontrolaVyhry.cpp
clean:
	\rm *.o *~ piskvorky
//////////////////////////////////////////////////////////////////////////
Error message:
*** Error code 127
make: Fatal error: Command failed for target `AI.o'
jack@opensolaris:~/pisk$ make
G++ -Wall -Wno-long-long -pedantic AI.cpp
sh: line 1: G++: not found

Last edited by shabbir; 25Aug2008 at 14:16.. Reason: Code block
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
Are you sure that make file generated that error? CC is defined as g++, but the error is that G++ doesn't exist. Solaris is case sensitive, so the error suggests you're not using the makefile posted.
Does the G++ command work from the command line (also, does the same command work if you use g++ instead of G++)?

Is the makefile you posted called Makefile (note the case) or something else? If something else then you need to specify the makefile name with -f (e.g. if it's called mymake.mk, the command is make -f mymake.mk).

What command caused the Error code 127?
0
C++Fun's Avatar, Join Date: Aug 2008
Newbie Member
Sorry, I copied bad error message, but the problem is the same. I tried to build it in various OS(solaris,kubuntu,knoppix), all from "live cd". I dont know why, but in knoppix OS is different error message. Makefile is named "Makefile".

//solaris + kubuntu//
make: Fatal error: Command failed for target `AI.o'
jack@opensolaris:~$ make
g++ -Wall -Wno-long-long -pedantic AI.cpp
sh: line 1: g++: not found
*** Error code 127
//knoppix//
g++ -Wall -Wno-long-long -pedantic AI.cpp
/UNIONFS/usr/bin/../lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/crt1.o: In function `_start':
../sysdeps/i386/elf/start.S:115: undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [AI.o] Error 1