I've just installed SDL 2 and I have some serious problems. This is my code:
#include <SDL2\SDL.h>
int main(int argc, char* argv[]) {
SDL_Init(SDL_INIT_VIDEO);
SDL_Quit();
return 0;
}
I am unable to compile because I get the error described in the title:
obj\Debug\main.o||In function SDL_main':|
C:\Users\myuser\Desktop\test 2000\main.cpp|5|undefined reference to SDL_Init'|
C:\Users\myuser\Desktop\test 2000\main.cpp|7|undefined reference to SDL_Quit'|
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libmingw32.a(main.o):main.c|| undefined reference to WinMain@16'|
||=== Build finished: 3 errors, 0 warnings ===|
I think you want
#define SDL_MAIN_HANDLED
in your main file, BEFORE the line
#include <SDL2/SDL.h>
from: https://stackoverflow.com/a/32343111/5214543
post the compiler commands. ex: g++/gcc ....
you are probably not linking the library.
http://content.gpwiki.org/index.php/SDL:Tutorials:Setup you should have the path to the lib, included in the ide. (I see you are using codeblocks)
add to the linker settings: -lmingw32 -lSDLmain -lSDL
http://www.sdltutorials.com/sdl-tutorial-basics
You need to add these to linker libraries with the same order:
mingw32
SDL2main
SDL2
Note that the order is important.
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