0

I had a problem with Visual Studio error LNK1561, so I investigated and found out, that as soon as I uncomment the #include part of code for the SDL headers, main turns into a macro, therefore it becomes an invalid entry point. I was thinking anyone here would have a fix for this problem. I'm posting the code here as well:

    #include <iostream>

#include <SDL.h>
#include "SDL_image.h"

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

    if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
    {
        std::cout << "Crappy error: " << SDL_GetError() << std::endl;
    }
    SDL_Window* window = SDL_CreateWindow("crappy window", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, 0);

    /*You have created a variable named window which is in the type of SDL_Window,
    SDL_Create Window creates a window and it's attributes are inside the (), the first
    one is the title, next is the x coordinate, then the y coordinate, then the width
    of the window, the height of the window, then the command that the window could
    understand you can put SDL_WINDOW_RESIZABLE if you want the window to be resizable etc.*/
    //Mind you that the (0,0) coordinate is in the top left of the screen so the greater the x value, the it moves to the right and the greater the y value, the more it moves down.

    SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);

    SDL_Texture* texture = IMG_LoadTexture(renderer, "Resources/water_tex/sea_texture_1.png"); //texture variable

    std::cin.get();
    return EXIT_SUCCESS;
}
  • 2
    Have you successfully linked the SDL libs? They do define main() themselves and your main() is called from there. – Yunnosch Feb 11 '19 at 20:30
  • Good read: https://www.libsdl.org/tmp/SDL/VisualC.html – Fluffy Feb 11 '19 at 20:32
  • Not too sure about this, but my guess is that since I started the project as an empty Visual C++ project, VS17 had a hard time deciding on the SubSystem. It works fine now, after going to Project -> Properties -> Linker -> System -> SubSystem, and setting it to Console (/SUBSYSTEM:CONSOLE), as found here: https://stackoverflow.com/a/31167593/10891507 – SnoopTheDog Feb 13 '19 at 15:38

0 Answers0