[ACCEPTED]-Undefined symbols. ld: symbol not found-linker

Accepted answer
Score: 11

The linker can't find the destructor for 9 the Obstacle class.

Is it in another object 8 file (perhaps Obstacle.o)? If so, add that 7 to the list of objects to link.

Is it supposed 6 to be an empty virtual destructor within 5 the class definition? In that case, make 4 sure you've written

virtual ~Obstacle() {}

and not

virtual ~Obstacle();

The first implements 3 the destructor; the second declares that 2 it exists, but is implemented somewhere 1 else.

Score: 1

Seems like you are missing the implementation 8 of the desctructor ~Obstacle that is anyway defined..

LD 7 is the linker, this means that everything 6 compiles fine but when it starts to link 5 binaries into one it can't find the destructor 4 for Obstacle used in your code..

Add

~Obstacle() {}

to your 3 class definition in .h file, or if you prefer 2 just define it ~Obstacle() and provide implementation 1 in .cpp file as ~Obstacle::Obstacle()

Score: 1

It might be that you declared the D'tor 2 but didn't implement it. Try to put {} in 1 the .h file, or:

Obstacle::~Obstacle()
{
}

in the cpp.

Score: 0

it also looks like the default constructors 1 are missing from RECTANGLE and CIRCLE.

Score: 0

You are missing a library. or have a broken 4 tool chain (which depends on the include 3 path for gcc).

Google turned up squat.. so 2 clarifying what you are actually trying to build 1 lets us help you more :)

More Related questions