This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Undefined References
On Sat, 2007-12-01 at 05:23 -0800, Brian Dessent wrote:
> Michael Sullivan wrote:
>
> > %.o : %.cpp
> > $(CXX) $(CFLAGS) $< -o $@ $(INC)
>
> This is wrong, you're missing -c.
>
> Brian
My Makefile is now:
michael@camille ourrpg $ cat Makefile
CXX=g++
CFLAGS=-W -Wall -pedantic
LIBS=`sdl-config --cflags --libs` -lSDL_image -lSDL_gfx -lSDL_ttf
INC = -I/usr/include/SDL
all: battle
battle: battle.o character.o
$(CXX) -o $@ battle.o character.o $(LIBS)
%.o : %.cpp
$(CXX) $(CFLAGS) $< -c $@ $(INC)
michael@camille ourrpg $ make
g++ -W -Wall -pedantic battle.cpp -c battle.o -I/usr/include/SDL
g++: battle.o: No such file or directory
battle.cpp: In member function 'SDL_Surface* battle::drawString(int,
int, char*)':
battle.cpp:72: warning: missing initializer for member
'SDL_Color::unused'
make: *** [battle.o] Error 1
michael@camille ourrpg $ make
g++ -W -Wall -pedantic character.cpp -c character.o -I/usr/include/SDL
g++: character.o: No such file or directory
make: *** [character.o] Error 1