Re: Undefined References

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 2007-12-01 at 09:26 -0600, Tom Browder wrote:
> You're getting the errors about vtable... because you have an
> undefined virtual function declared in character.h.
> 
> Getting rid of the virtual attribute eliminates those errors and
> allows a successful build (and you can eliminate the virtual
> destructor).
> 
The virtual destructor is there because g++ was giving me a warning
about setCurrentSprite(int), which will be implemented in classes Ally
and Enemy - both descended from Character.  I've commented out the
virtual destructor in character.h and used your Makefile with the
following output:

michael@camille ourrpg $ make
g++ -W -Wall -pedantic `sdl-config --cflags` -c battle.cpp
character.h:8: warning: 'class Character' has virtual functions but
non-virtual destructor
battle.cpp: In member function 'SDL_Surface* battle::drawString(int,
int, char*)':
battle.cpp:72: warning: missing initializer for member
'SDL_Color::unused'
g++ -W -Wall -pedantic `sdl-config --cflags` -c character.cpp
character.h:8: warning: 'class Character' has virtual functions but
non-virtual destructor
g++ -o battle battle.o character.o `sdl-config --libs` -lSDL_image
-lSDL_gfx -lSDL_ttf
battle.o: In function `battle::battle()':
battle.cpp:(.text+0x84b): undefined reference to
`Character::Character()'
battle.o: In function `battle::battle()':
battle.cpp:(.text+0xc37): 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
make: *** [battle] Error 1

> Then you can concentrate on other problems in the overall program, if any.
> 
> I've attached a little cleaner Makefile for your consideration.
> 
> -Tom


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux