为糟糕的问题标题道歉,我不知道如何问这个。我在尝试编译我的 GLUT 游戏时遇到 LNK2019 错误,我无法找出导致错误的原因。
错误: 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)
小行星.h
class asteroid
{
public:
asteroid(void); //constructer
~asteroid(void); //deconstructer
void Draw();
void createAsteroid();
float generateAsteroidLocation(float a, float b);
void animateAsteroid();
};
asteroid.cpp(麻烦功能)
#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(我得到错误的函数)
void idle(void)
{
glutPostWindowRedisplay(glutGetWindow());
Asteroid.animateAsteroid();
}
对于解决此问题的任何帮助,我将不胜感激。
谢谢,丹。