Jason Gray
Jason Gray

Reputation: 97

error LNK2019: unresolved external symbol classes

I get the error below when i call new TerrainClass() from the main, tried for hours to fix it, help please.

error LNK2019: unresolved external symbol "public: __thiscall TerrainClass::TerrainClass(void)" (??0TerrainClass@@QAE@XZ) referenced in function "void __cdecl init(void)" (?init@@YAXXZ)

GLDrawObject.h

#pragma once

class GLDrawObject
{

};

Terrain.cpp

#pragma once

TerrainClass::TerrainClass() : GLDrawObject()
{

}

Terrain.h

#pragma once

#include "GLDrawObject.h"

class TerrainClass : public GLDrawObject
{
public: 
    TerrainClass();
};

Upvotes: 0

Views: 75

Answers (1)

ildjarn
ildjarn

Reputation: 62995

Firstly, your Terrain.cpp should be as follows:

#include "Terrain.h"

TerrainClass::TerrainClass() : GLDrawObject()
{

}

Secondly, you are getting a linker error, not a compiler error; once compiled, you need to link Terrain.o with the rest of your object files.

Upvotes: 1

Related Questions