i'm trying to make SDL work with my MVS2015 without success so far, i really want to get this to work, so i'll explain every step i made. First i downloaded the prebuild SDL2 library from the SDL installation guide: https://wiki.libsdl.org/Installation , then unpacked. Made a new console application in MVS2015, opened the project property page and set the "Include Directories" correctly, i triple checked it, also did this for "Library Directories". Then i went to "Linker" -> "Input" and added SDL2.lib to "Additional Dependencies". So far so good, my code should work with SDL now right? I made a short main to test if it works:
#include <SDL.h>
int main(){
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Quit();
return 0;}
And if i build it i get these error messages:
Severity Code Description Project File Line
Error LNK1120 1 unresolved externals sdltry4 c:\users\myuser\documents\visual studio 2015\Projects\sdltry4\Debug\sdltry4.exe 1
Error LNK2019 unresolved external symbol _WinMain@16 referenced in function "int __cdecl __scrt_common_main_seh(void)" (?__scrt_common_main_seh@@YAHXZ) sdltry4 c:\Users\Bandan\documents\visual studio 2015\Projects\sdltry4\sdltry4\MSVCRT.lib(exe_winmain.obj) 1
Would really appriciate the help.
You need to add this define before including the main SDL header:
#define SDL_MAIN_HANDLED
#include "SDL.h"
SDL.h includes SDL_main.h, which has an interesting bit about wanting to use its own WinMain definition, which can be disabled, since you have your own main.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With