I just started looking at the basics of openGL, but I keep getting error LNK2019 and I don't know what's causing it or how to fix it.
#include "stdafx.h"
#include <cstdlib>
#include <GLTools.h>
#include <GLShaderManager.h>
//Include OpenGL header files, so that we can use OpenGL
#ifdef __APPLE__
#include <OpenGL/OpenGL.h>
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
using namespace std;
GLBatch a;
GLShaderManager b;
//Called when a key is pressed
void handleKeypress(unsigned char key, int x, int y){
switch(key){
case 27: //Escape key
exit(0);
}
}
//Initializes 3D rendering
void initRendering(){
glEnable(GL_DEPTH_TEST);
}
//Called when the window is resized
void handleResize(int w, int h){
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, (double)w / (double)h, 1.0, 200.0);
}
//Draws the 3D scene
void drawScene(){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective
glLoadIdentity(); //Reset the drawing perspective
GLfloat colour[] = {1.0f, 0.0f, 0.0f, 1.0f};
b.UseStockShader(GLT_SHADER_IDENTITY, colour);
a.Draw();
glutSwapBuffers(); //Draw the scene on the screen
}
//Only called once, in main
void setupScene(){
glClearColor(0.98f, 0.625f, 0.12f, 1.0f);
b.InitializeStockShaders();
GLfloat vertices[] = {0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f,
1.0f, 0.0f, 0.0f};
a.Begin(GL_TRIANGLES, 3);
a.CopyVertexData3f(vertices);
a.End();
}
int main(int argc, char** argv){
//Initialize GLUT
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(400, 400);
//Create the window
glutCreateWindow("Window name");
initRendering();
//Set handler functions
glutDisplayFunc(drawScene);
glutKeyboardFunc(handleKeypress);
glutReshapeFunc(handleResize);
setupScene();
glutMainLoop();
return 0;
}
Errors:
1>gltools test.obj : error LNK2019: unresolved external symbol "public: virtual void __thiscall GLBatch::Draw(void)" (?Draw@GLBatch@@UAEXXZ) referenced in function "void __cdecl drawScene(void)" (?drawScene@@YAXXZ)
1>gltools test.obj : error LNK2019: unresolved external symbol "public: int __cdecl GLShaderManager::UseStockShader(enum GLT_STOCK_SHADER,...)" (?UseStockShader@GLShaderManager@@QAAHW4GLT_STOCK_SHADER@@ZZ) referenced in function "void __cdecl drawScene(void)" (?drawScene@@YAXXZ)
1>gltools test.obj : error LNK2019: unresolved external symbol "public: void __thiscall GLBatch::End(void)" (?End@GLBatch@@QAEXXZ) referenced in function "void __cdecl setupScene(void)" (?setupScene@@YAXXZ)
1>gltools test.obj : error LNK2019: unresolved external symbol "public: void __thiscall GLBatch::Begin(unsigned int,unsigned int,unsigned int)" (?Begin@GLBatch@@QAEXIII@Z) referenced in function "void __cdecl setupScene(void)" (?setupScene@@YAXXZ)
1>gltools test.obj : error LNK2019: unresolved external symbol "public: bool __thiscall GLShaderManager::InitializeStockShaders(void)" (?InitializeStockShaders@GLShaderManager@@QAE_NXZ) referenced in function "void __cdecl setupScene(void)" (?setupScene@@YAXXZ)
1>gltools test.obj : error LNK2019: unresolved external symbol "public: void __thiscall GLBatch::CopyVertexData3f(float (*)[3])" (?CopyVertexData3f@GLBatch@@QAEXPAY02M@Z) referenced in function "public: void __thiscall GLBatch::CopyVertexData3f(float *)" (?CopyVertexData3f@GLBatch@@QAEXPAM@Z)
1>gltools test.obj : error LNK2019: unresolved external symbol "void __cdecl gltSetWorkingDirectory(char const *)" (?gltSetWorkingDirectory@@YAXPBD@Z) referenced in function _main
1>gltools test.obj : error LNK2019: unresolved external symbol "public: __thiscall GLBatch::GLBatch(void)" (??0GLBatch@@QAE@XZ) referenced in function "void __cdecl `dynamic initializer for 'a''(void)" (??__Ea@@YAXXZ)
1>gltools test.obj : error LNK2019: unresolved external symbol "public: __thiscall GLShaderManager::GLShaderManager(void)" (??0GLShaderManager@@QAE@XZ) referenced in function "void __cdecl `dynamic initializer for 'b''(void)" (??__Eb@@YAXXZ)
1>gltools test.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall GLBatch::~GLBatch(void)" (??1GLBatch@@UAE@XZ) referenced in function "void __cdecl `dynamic atexit destructor for 'a''(void)" (??__Fa@@YAXXZ)
1>gltools test.obj : error LNK2019: unresolved external symbol "public: __thiscall GLShaderManager::~GLShaderManager(void)" (??1GLShaderManager@@QAE@XZ) referenced in function "void __cdecl `dynamic atexit destructor for 'b''(void)" (??__Fb@@YAXXZ)
Anyone know why this is happening?