[SDL] OT - Undefined references in my project

Josh Matthews mrlachatte at gmail.com
Sat Dec 1 06:53:39 PST 2007


The makefile in your text file is different from the one in your email, so
I'll go by the text file:

michael at camille ourrpg $ nl Makefile
     1  CC=g++
     2  CFLAGS=-W -Wall -pedantic
     3  LIBS=`sdl-config --cflags --libs` -lSDL_image -lSDL_gfx -lSDL_ttf
     4
     5  character.o: character.cpp
     6          reset; $(CC) $(CFLAGS) -c character.cpp;rm *~
     7
     8  battle.o: battle.cpp
     9          reset; $(CC) $(CFLAGS) -c battle.cpp character.o $(LIBS); rm *~
    10
    11  all: battle.o character.o
    12          reset; $(CC) $(CFLAGS) battle.o character.o $(LIBS) -o
battle; rm *~

It says here you're outputting the compiled battle.cpp as character.o.  This
will cause all kinds of problems for you.

On Dec 1, 2007 7:24 AM, Michael Sullivan <michael at espersunited.com> wrote:

> I'm sorry to ask this here, but I've tried a few other lists, and
> they've given me a few suggestions (which didn't work), so I thought I'd
> try here.  I suspect this has something to do with my Makefile.  This is
> the first project I've done when I've attempted to use a Makefile.  My
> full code is too long to politely past into an email, but I've posted it
> at http://www.espersunited.com/~michael/needhelp.txt<http://www.espersunited.com/%7Emichael/needhelp.txt>
>
> Here's the Makefile:
>
> CC=g++
> CFLAGS=-W -Wall -pedantic
> LIBS=`sdl-config --cflags --libs` -lSDL_image -lSDL_gfx -lSDL_ttf
>
> character.o: character.cpp
>        reset; $(CC) $(CFLAGS) -c character.cpp;rm *~
>
> battle.o: battle.cpp
>        reset; $(CC) $(CFLAGS) -c battle.cpp -I/usr/include/SDL/; rm *~
>
> all: battle.o character.o
>        reset; $(CC) $(CFLAGS) battle.o character.o $(LIBS) -o battle; rm
> *~
>
> character.o and battle.o are created, but when I try to make all, I get
> the following errors:
>
> battle.o: In function `battle::battle()':
> battle.cpp:(.text+0x9e3): undefined reference to
> `Character::Character()'
> battle.cpp:(.text+0xb35): undefined reference to
> `Character::~Character()'
> battle.cpp:(.text+0xb83): undefined reference to
> `Character::~Character()'
> battle.cpp:(.text+0xbd1): undefined reference to
> `Character::~Character()'
> battle.cpp:(.text+0xc16): undefined reference to
> `Character::~Character()'
> battle.o: In function `battle::battle()':
> battle.cpp:(.text+0xf19): undefined reference to
> `Character::Character()'
> battle.cpp:(.text+0x106b): undefined reference to
> `Character::~Character()'
> battle.cpp:(.text+0x10b9): undefined reference to
> `Character::~Character()'
> battle.cpp:(.text+0x1107): undefined reference to
> `Character::~Character()'
> battle.cpp:(.text+0x114c): undefined reference to
> `Character::~Character()'
> character.o: In function `Character::Character(char*, long, long)':
> character.cpp:(.text+0xdb): undefined reference to `vtable for
> Character'
> character.o: In function `Character::Character(char*, long, long)':
> character.cpp:(.text+0x12d): undefined reference to `vtable for
> Character'
> collect2: ld returned 1 exit status
>
> I don't understand why.  This is my first SDL project, and my first
> multifile C/C++ project, so I'm kinda out of my element here.  Thank you
> in advance for your help...
> -Michael Sullivan-
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>



-- 
Cheers,
Josh

PGP: http://revvy.box43.net/Josh_Matthews.asc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20071201/73d9a14c/attachment-0008.htm>


More information about the SDL mailing list