0

I am trying to use SDL in a project. I used vcpkg to install the libraries and used this tutorial to do so https://www.youtube.com/watch?v=0h1lC3QHLHU&t=306s. I started just including the header file like so.

#include <iostream>
#include <SDL2/SDL.h>

int main()
{
    return 0;
}

After i press play, the program compiles but the linker throws this errors:

Error LNK2019 unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ) Tetris F:\Coding\C++\Tetris\Tetris\MSVCRTD.lib(exe_main.obj) 1

and this warnings:

Warning The 'packages' element is not declared. Tetris F:\Coding\C++\Tetris\Tetris\packages.config 2

Warning C26812 The enum type 'SDL_bool' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). Tetris F:\games\vcpkg\installed\x86-windows\include\SDL2\SDL_rect.h 113

Can you help me with this? im using Visual Studio 2019 btw.

I know that the error in theory is because the linker doesn't find a body for the method _main but i have no idea were it is but also how to add a body to it if it is not the main method.

1 Answers1

-1

put #define SDL_MAIN_HANDLED before including SDL like this:

#define SDL_MAIN_HANDLED
#include <SDL2/SDL.h>
rohan
  • 124
  • 3
  • 9