views:

43

answers:

3

I'm trying to compile (make) a game source and it seems that my gRace.cpp file is being excluded or something because it keeps returning undefined reference errors for all my gRace class methods.

libtron.a(libtron_a-gGame.o): In function `gGame::StateUpdate()':
gGame.cpp:(.text+0x99e9): undefined reference to `gRace::Reset()'
libtron.a(libtron_a-gGame.o): In function `gGame::Analysis(float)':
gGame.cpp:(.text+0xad48): undefined reference to `gRace::Sync(int, int, int)'
gGame.cpp:(.text+0xad4d): undefined reference to `gRace::Done()'
gGame.cpp:(.text+0xad61): undefined reference to `gRace::Winner()'
gGame.cpp:(.text+0xb786): undefined reference to `gRace::End()'
libtron.a(libtron_a-gWinZone.o): In function `gWinZoneHack::OnEnter(gCycle*, float)':
gWinZone.cpp:(.text+0x9206): undefined reference to `gRace::ZoneHit(ePlayerNetID*)'
libtron.a(libtron_a-gWinZone.o): In function `gWinZoneHack::gWinZoneHack(eGrid*, eCoord const&, bool)':
gWinZone.cpp:(.text+0xda96): undefined reference to `gRace::NewZone(gWinZoneHack*)'
libtron.a(libtron_a-gWinZone.o): In function `gWinZoneHack::gWinZoneHack(eGrid*, eCoord const&, bool)':
gWinZone.cpp:(.text+0xdcc6): undefined reference to `gRace::NewZone(gWinZoneHack*)'
collect2: ld returned 1 exit status

I'm including the gRace.h file in both files via:

#include "gRace.h"

Any ideas on what might be causing it to not be processed?

A: 

This apprears to be a linking error and not a compilation error. Most likely, you are missing some external libraries that you should be linking against.

cristobalito
+2  A: 

Not including the header file would cause undefined function compiler errors. These are linker errors, which means the actual source file isn't being linked with the other files (that is, it has nothing to do with whether or not you included gRace.h in the right places). Check your build script to ensure gRace.cpp is being linked in properly

Michael Mrozek
Thanks for pointing that out. I completely forgot to add the link for gRace! I guess I just expected it to magically add that...
animuson
+1  A: 

If it is an automake project you are missing gRace.cpp in your _SOURCES section in the Makefile.am.

DiggyF
+1 for suggesting the Makefile.am!
animuson