Stumped (SDL2 compiling issue)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$ g++ -o shiity.exe shittydungeon.cpp -lmingw32 -lSDL2 -lSDL2_image -lSDL2main
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../libSDL2main.a(SDL_windows_main.o)
:SDL_windows_main.c:(.text+0x4): undefined reference to `SDL_SetMainReady'
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../libSDL2main.a(SDL_windows_main.o)
:SDL_windows_main.c:(.text+0x41): undefined reference to `SDL_strdup'
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../libSDL2main.a(SDL_windows_main.o)
:SDL_windows_main.c:(.text+0x62): undefined reference to `SDL_isspace'
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../libSDL2main.a(SDL_windows_main.o)
:SDL_windows_main.c:(.text+0x82): undefined reference to `SDL_malloc'
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../libSDL2main.a(SDL_windows_main.o)
:SDL_windows_main.c:(.text+0xd5): undefined reference to `SDL_isspace'
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../libSDL2main.a(SDL_windows_main.o)
:SDL_windows_main.c:(.text+0x14b): undefined reference to `SDL_isspace'
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../libSDL2main.a(SDL_windows_main.o)
:SDL_windows_main.c:(.text+0x18e): undefined reference to `SDL_isspace'
collect2: ld returned 1 exit status 

Using mingw / msys.
I don't know compilers enough to understand this...
I think it has to do with linking.
But i opened the libsdl2main.a file and ctl-f'ed "SDL_SetMainReady" and found it.
It was in the lib file in mingw folder.
Yea, I hope this will be a silly error.
Anyways, this is what i get if i don't put -lSDL2main:
1
2
3
4
5
$ g++ -o gay.exe shittymain.cpp -lmingw32 -lSDL2 -lSDL2_image
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/libmingw32.a(main.o): In function `main':
C:\MinGW\msys\1.0\src\mingwrt/../mingw/main.c:73: undefined reference to `WinMai
n@16'
collect2: ld returned 1 exit status
I had the same issue. I wasted so much time... and the issue was the wrong order of compiler flag...(your flag are ordered wrong - lSDL2main is at the end, so compiler haven't linked SDL_SetMainReady,SDL_strdup,SDL_issace,SDL_malloc yet and it's trying to use this them linking -lSDL2)
so make sure You set compiler flag are in right order.
The order is:
-lmingw32
-lSDL2main
-lSDL2
-lSDL2_image
-lSDL2_ttf
-lSDL2_mixer
- any other additional library You wish to add.

Last edited on
I love you man.
Topic archived. No new replies allowed.