0

** Edit, here's the pictures of my linking stuff... : **

https://i.stack.imgur.com/w8F3z.jpg

So, I keep getting the "unresolved Externals" error which I can't fix. I've read lots of different posts about this on different sites none of them have helped at all. Still have no idea what to do.

Someone told me something about defining and declaring variables, however I didn't understand what he meant...

Would be great if someone could tell me what to modify in my code instead. :)

Error list :

Error   5   error LNK1120: 3 unresolved externals   C:\Users\MyName\Desktop\SDL_Game\Debug\SDL_Game.exe 1   1   SDL_Game

Error   3   error LNK2001: unresolved external symbol "public: static bool CoreEngine::isRunning" (?isRunning@CoreEngine@@2_NA) C:\Users\MyName\Desktop\SDL_Game\SDL_Game\CoreEngine.obj    SDL_Game

Error   2   error LNK2019: unresolved external symbol "public: class Window __thiscall CoreEngine::window(void)" (?window@CoreEngine@@QAE?AVWindow@@XZ) referenced in function "public: __thiscall CoreEngine::CoreEngine(void)" (??0CoreEngine@@QAE@XZ)    C:\Users\MyName\Desktop\SDL_Game\SDL_Game\CoreEngine.obj    SDL_Game

Error   4   error LNK2019: unresolved external symbol _SDL_main referenced in function _main    C:\Users\MyName\Desktop\SDL_Game\SDL_Game\SDL2main.lib(SDL_windows_main.obj)    SDL_Game

All Project Files :

CoreEngine.h

#pragma once
#include <SDL.h>
#include "Window.h"

class CoreEngine
{
public:
    Window window();

    CoreEngine();
    ~CoreEngine();

    static bool isRunning;

private:

};

CoreEngine.cpp

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

CoreEngine::CoreEngine()
{

    CoreEngine::isRunning = false;
    CoreEngine::window;

    if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
    {
        CoreEngine::isRunning = false;
        std::cout << "Failed To Initialize SDL" << std::endl;
        system("PAUSE");
        SDL_Quit();
    }
    else 
    {
        while (CoreEngine::isRunning)
        {

        }
    }
}


CoreEngine::~CoreEngine()
{

}

Window.h

#pragma once
#include <SDL.h>

class Window
{
public:
    Window();
    ~Window();

    SDL_Window* window;

private:
    int CreateWindow();
};

Window.cpp

#include "Window.h"


Window::Window()
{
    CreateWindow();
}


Window::~Window()
{

}

int Window::CreateWindow()
{
    window = SDL_CreateWindow("Engine Title", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS);

    if (window == NULL)
    {
        return -1;
    }
    else
    {
        return 0;
    }
}
Happy Crayfish
  • 47
  • 1
  • 11
  • you need to link with SDL library – Cheers and hth. - Alf Oct 26 '15 at 18:51
  • Code's right (maybe), project is wrong. You're not linking with SDL_Game library – Daniel Strul Oct 26 '15 at 18:51
  • @Cheersandhth.-Alf It is linked, everything is included, all files are in the linker input, and it's added to external libraries thing. I'll add a screenshot to the post – Happy Crayfish Oct 26 '15 at 18:54
  • @Cheersandhth.-Alf Added pictures... – Happy Crayfish Oct 26 '15 at 19:08
  • @DanielStrul Added pictures to show my linking stuff. – Happy Crayfish Oct 26 '15 at 19:09
  • OK, then library paths are good. Next step is to check that SDL_GAME library is included in the linker inputs (Configuration properties -> Linker -> Input, see http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix for details). If the library is included, then it's another problem... and I'm out of ideas... – Daniel Strul Oct 26 '15 at 19:14
  • @DanielStrul SDL_GAME? Do you mean the SDL2.lib and SDL2main.lib or did i miss something? Here's my current inputs : http://imgur.com/mqBq3VB – Happy Crayfish Oct 26 '15 at 19:46
  • @Happy Crayfish, Yes I meant that... and I'm out of ideas... – Daniel Strul Oct 26 '15 at 19:47
  • @DanielStrul I feel like this has been wrongly marked as a duplicate since none of the other answers seem to work.... :/ – Happy Crayfish Oct 26 '15 at 20:25
  • @Happy Crayfish, maybe so... But considering that I've been on SO for only a few days, I have no ideas of how things are done here yet. What we know so far is that (1) you have correctly added the SDL librairies, (2) but the linker still can't find `_SDL_main`. My advice would be to google http://www.google.com/search?q=error+LNK2019%3A+%22unresolved+external+symbol+_SDL_main%22 . This error seems to be pretty common with this library, so hopefully you'll find the answer. – Daniel Strul Oct 26 '15 at 20:49
  • @DanielStrul I think I fixed it, I tried creating a object in the wrong place I think... Removing all objects fixed all problems. – Happy Crayfish Oct 26 '15 at 21:02
  • Coool! Spending the whole day running after a small error? You've just had a developer's normal day then! CU around :-) – Daniel Strul Oct 26 '15 at 21:05
  • @DanielStrul Nevermind, It's back again... xD – Happy Crayfish Oct 26 '15 at 21:38

0 Answers0