2

after the last 2 days, I returned to OpenGL to get it working. Almost got it as well. (Why do I say almost? It made a window once) Problem is now it won't work at all. Something to do with Undefined references. Below is my code

#include <iostream>
#include <string>
#include <sstream>
#include <stdlib.h>
#include <stdio.h>
#include <ctime>

#include <SDL2/SDL.h>
#include <GL/glew.h>

#include "map.h"

using namespace std;

int main(int argc, char **argv) 
{
    SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS);
    SDL_Window *window = SDL_CreateWindow("Tycoon Example",SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED,640,480,SDL_WINDOW_OPENGL);
    SDL_GLContext glcontext = SDL_GL_CreateContext(window);

    if (window == NULL)
    {
        printf("Could not create window: %s\n", SDL_GetError());
        return 1;
    }

    Game_Map world = Game_Map(20,20); //Ignore this. It is class that is included in map.h

    return 0; 
}

I am unsure what is causing this. I have kept the code at a basic complexity to cut down external influences. Can you think of what may cause this? My laptop seems to be x64 but I am unsure as there are program folders for x86 as well. But my focus is solving what this error is meaning and what could cause it. Any advice?

Jeremy Beare
  • 489
  • 3
  • 8
  • 22
  • Does this help: http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix? – πάντα ῥεῖ Apr 13 '14 at 11:15
  • Had a read through and I think I understand what the error is. Now I'm wondering how does it relate to my situation? – Jeremy Beare Apr 13 '14 at 11:19
  • You should check all of the answers there. – πάντα ῥεῖ Apr 13 '14 at 11:21
  • @JeremyBeare: You should include your compile line in your question. You're probably missing something like `-lsdl`. – Zeta Apr 13 '14 at 11:22
  • @ Zeta - I haven't heard of this compile line. Where would I find it in Code Blocks? Actually, a better question would be what is a compile line? – Jeremy Beare Apr 13 '14 at 11:24
  • NVM, is this it? mingw32-g++.exe -o "bin\Debug\Tycoon Example.exe" obj\Debug\main.o obj\Debug\map.o -lmingw32 -lSDL2main -lSDL2 -lopengl32 -lglew32 -lglu32 obj\Debug\main.o: In function `SDL_main': – Jeremy Beare Apr 13 '14 at 11:25

0 Answers0