when my code is:
int WinMain(int argc, char **argv) {
int SDL_Init(SDL_INIT_VIDEO);
return 0;
}
it's working fine but when my code is:
int WinMain(int argc, char **argv) {
if(SDL_Init(SDL_INIT_VIDEO) < 0) {
// nothing here
}
return 0;
}
I'm getting this error:
undefined reference to 'SDL_Init'
I'm on VSC 1.32.1 window 10 mingw32 6.3.0
In your first code you delcare an int
called SDL_Init
, lets change the names to make it more obvious:
int WinMain(int argc, char **argv) {
int variable_name(some_value);
}
In your second code you call a function:
int WinMain(int argc, char **argv) {
if(some_function(some_value) < 0) { }
}
Thats why in the first you dont get an error, but in the second you do. Seems like there is no some_function
aka SDL_Init
defined, which can be caused by not linking corretly, see here for how to fix that.