1

I got a LNK1561 entry point must be defined error i tried somethings my self as stsyem settings to console and it still doesn't work. Here is my code for every class the SDl.h is from the SDL.h donwload page.

main.cpp:

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

int main(int argc, char** argv) {

std::cout << "Enter any ket to quit...";
int a;
std::cin >> a;

return 0;

}

MainGame.cpp:

#include "MainGame.h"

MainGame::MainGame()
{

_window = nullptr;
_screenHeight = 1028;
_screenWidth = 768;

}


MainGame::~MainGame()
{
}

void MainGame::run() {
    InitSystems();
}

void MainGame::InitSystems() {
    SDL_Init(SDL_INIT_EVERYTHING);

    _window = SDL_CreateWindow("title", SDL_WINDOWPOS_CENTERED, 
    SDL_WINDOWPOS_CENTERED, 1028, 768, SDL_WINDOW_OPENGL);
    }

MainGame.h:

#pragma once

#include <SDL/SDL.h>

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

    void run();

    void InitSystems();

private:
    SDL_Window* _window;
    int _screenWidth;
    int _screenHeight;
};

Allt his code is to open an Windowed frame on your computer en open an console with the text Press Any ket to quit... If i remove the SDL.h include and the SDL code it all works if i put the include back and not the SDL code it gives the error again.

user0042
  • 7,917
  • 3
  • 24
  • 39
Yorick
  • 51
  • 8
  • 2
    Possible duplicate of [SDL2: LNK1561: entry point must be defined](https://stackoverflow.com/questions/18672303/sdl2-lnk1561-entry-point-must-be-defined) – tambre Oct 07 '17 at 08:02
  • no i tried every thing from that post to and did not work – Yorick Oct 07 '17 at 08:18
  • @Yorick Have you tried using MainGame in your main function? Chances that the compiler assumes that it is never used and you do not get the `#include ` directive to work. Also, consider changing `#include ` to `#include "SDL/SDL.h"`. – Serkan Pekçetin Oct 11 '17 at 05:08
  • @SerkanPekçetin i have changed the include to "SDL/SDL.h" and still getting same error :( – Yorick Oct 12 '17 at 17:50
  • 1
    Can you try [this](https://wiki.libsdl.org/SDL_SetMainReady) – Serkan Pekçetin Oct 12 '17 at 20:01
  • @SerkanPekçetin got new error when i did this: #define SDL_MAIN_HANDLED #include "MainGame.h" int main(int argc, char *argv[]){ SDL_SetMainReady(); SDL_Init(SDL_INIT_VIDEO); SDL_Quit(); return 0; } – Yorick Oct 15 '17 at 08:50
  • errors: Error LNK1120 4 unresolved externals Game C:\Users\yoric\source\repos\Game\Debug\Game.exe 1 Error LNK2019 unresolved external symbol _SDL_SetMainReady referenced in function _main Game C:\Users\yoric\source\repos\Game\Game\main.obj 1 Error LNK2019 unresolved external symbol _SDL_Init referenced in function _main Game C:\Users\yoric\source\repos\Game\Game\main.obj 1 – Yorick Oct 15 '17 at 08:50
  • Error LNK2001 unresolved external symbol _SDL_Init Game C:\Users\yoric\source\repos\Game\Game\MainGame.obj 1 Error LNK2019 unresolved external symbol _SDL_Quit referenced in function _main Game C:\Users\yoric\source\repos\Game\Game\main.obj 1 Error LNK2019 unresolved external symbol _SDL_CreateWindow referenced in function "public: void __thiscall MainGame::InitSystems(void)" (? InitSystems@MainGame@@QAEXXZ) Game C:\Users\yoric\source\repos\Game\Game\MainGame.obj 1 – Yorick Oct 15 '17 at 08:50
  • @SerkanPekçetin your suggestion fixed the entry point issue for me. Suggest making an answer out of it. – Matt Brown Aug 02 '18 at 11:20
  • @MattBrown Glad that helped. I have just put it as an answer per your suggestion. – Serkan Pekçetin Aug 03 '18 at 12:11

1 Answers1

1

Have you tried using MainGame in your main function? Chances that the compiler assumes that it is never used and you do not get the #include <SDL/SDL.h> directive to work. Also, consider changing #include <SDL/SDL.h> to #include "SDL/SDL.h".

Also you might consider using SDL_SetMainReady for the cases that you are not using SDL_Main as the entry point.

Serkan Pekçetin
  • 658
  • 7
  • 14