0

Apologies for the poor question title, I wasn't sure how to ask this. I am getting a LNK2019 error when trying to compile my GLUT game and I cannot spot what is causing the error.

The error: main.obj : error LNK2019: unresolved external symbol "public: void __thiscall asteroid::animateAsteroid(void)" (?animateAsteroid@asteroid@@QAEXXZ) referenced in function "void __cdecl idle(void)" (?idle@@YAXXZ)

asteroid.h

class asteroid
{
public:
asteroid(void); //constructer
~asteroid(void); //deconstructer

void Draw();
void createAsteroid();
float generateAsteroidLocation(float a, float b);
void animateAsteroid();
};

asteroid.cpp (the trouble function)

#include "asteroid.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <ctime>
#include <GL/glut.h>

float asteroidX,asteroidY, V;
bool locationGenerated = false;

asteroid::asteroid(void){

}

asteroid::~asteroid(void){

}
void animateAsteroid(){
float dt = 3500;
float Dx = 25 - asteroidX;
float Dy = 25 - asteroidY;
float Cx = asteroidX + Dx / sqrt(Dx*Dx+Dy*Dy) * V * dt;
float Cy = asteroidY + Dy / sqrt(Dx*Dx+Dy*Dy) * V * dt;
asteroidX = Cx;
asteroidY = Cy;
}

Main.cpp (the function where I am getting the error)

void idle(void)
{
glutPostWindowRedisplay(glutGetWindow());
Asteroid.animateAsteroid();
}

I would greatly appreciate any help in resolving this issue.

Thanks, Dan.

Daniel Flannery
  • 1,166
  • 8
  • 23
  • 51

1 Answers1

1

In the asteroid.cpp file, you're missing the class name in the method declaration:

void asteroid::animateAsteroid(){
...
ales_t
  • 1,967
  • 11
  • 10
  • Correct. I'm embarrassed at how obvious that was. I've been staring at this code for too long. Thank you for your speedy answer :). – Daniel Flannery Nov 25 '12 at 17:43