Horrible Error: LNK2019

Hey. I have a real problem. I am making a small 2D game and am trying to set up the SDL, but when i try compile it, these horrible error appears:

Error 2 error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function "private: void __thiscall stellar::drawGame(void)" (?drawGame@stellar@@AAEXXZ)

Error 3 error LNK2019: unresolved external symbol __imp__glClearColor@16 referenced in function "private: void __thiscall stellar::initSystems(void)" (?initSystems@stellar@@AAEXXZ)

Error 4 error LNK2019: unresolved external symbol __imp__glClearDepth@8 referenced in function "private: void __thiscall stellar::drawGame(void)" (?drawGame@stellar@@AAEXXZ)

Error 5 error LNK1120: 3 unresolved externals

Please solve this!


Here's the code:

stellar.h

#pragma once
#include <SDL.h>
#include <glew.h>
enum class GameState { PLAY, EXIT };




class stellar
{
public:
stellar::stellar();
stellar::~stellar();
void run();



private:
SDL_Window* _window;
int _screenWidth;
int _screenHeight;
void initSystems();
void processInput();
void gameloop();
void drawGame();
GameState _gameState;

};






stellar.cpp

#include "stellar.h"
#include <glew.h>
#include <iostream>

#include <string>

void fatalError(std::string errorString) {
std::cout << errorString << std::endl;
std::cout << "Enter any key to Quit...";
int tmp;
std::cin >> tmp;
SDL_Quit();
}

stellar::stellar()
{
_window = nullptr;
_screenWidth = 1024;
_screenHeight = 710;
_gameState = GameState::PLAY;
}


stellar::~stellar()
{
}


void stellar::run() {
initSystems();

gameloop();
}

void stellar::initSystems(){
SDL_Init(SDL_INIT_EVERYTHING);
_window = SDL_CreateWindow("Stellar Explorer 2(D)", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, _screenWidth, _screenHeight, SDL_WINDOW_OPENGL);
if (_window == nullptr){ fatalError("SDL_Window could not be created!"); }

SDL_GLContext glContext = SDL_GL_CreateContext(_window);
if (glContext == nullptr){ fatalError("SDL_GL context could not be created!"); }





SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

glClearColor(0.0f, 0.0f, 1.0f, 1.0f);






}

void stellar::gameloop(){
while (_gameState != GameState::EXIT){
processInput();



stellar::drawGame();




}
}
void stellar::processInput() {
SDL_Event evnt;

while (SDL_PollEvent(&evnt)){
switch (evnt.type) {
case SDL_QUIT:
_gameState = GameState::EXIT;
break;
case SDL_MOUSEMOTION:
std::cout << evnt.motion.x << " " << evnt.motion.y << std::endl;
break;
}
}
}







void stellar::drawGame(){
glClearDepth(1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);




SDL_GL_SwapWindow(_window);

}




main.cpp

#include "stellar.h"
#include <iostream>


int main(int argc, char** argv) {
stellar Stellar;
Stellar.run();
return 0;
}


PLEASE HELP



Sounds you like you are linking SDL and your project correctly. Go double check you set up that stuff right.
You forgot to link to opengl32, or you're using GCC and need to reorder the libraries.
Topic archived. No new replies allowed.