0

Hello I Am Using SDL2 With MINGW To Make A Simple Window And It Cannot Compile, The Code Is The Following And The Result Is The Following:

 #include <iostream>
 #include "SDL/SDL.h" 
 using namespace std
 int main(int argc, char* args[])
 {
     SDL_Window *win = SDL_CreateWindow("WINDOW TEST", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_SHOWN);
     main_t:
     // this is the loop
     goto main_t;
     return 0;
 }

Build errors:

c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../.. ../libSDL2main.a(SDL_windows_main.o): In function `main_getcmdline':
/Users/slouken/release/SDL/SDL2-2.0.5-source/foo-x86/../src/main/windows/SDL_windows_main.c:142: undefined reference to `SDL_wcslen'
/Users/slouken/release/SDL/SDL2-2.0.5-source/foo-x86/../src/main/windows/SDL_windows_main.c:142: undefined reference to `SDL_iconv_string'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libSDL2main.a(SDL_windows_main.o): In function `ParseCommandLine':
/Users/slouken/release/SDL/SDL2-2.0.5-source/foo-x86/../src/main/windows/SDL_windows_main.c:54: undefined reference to `SDL_isspace'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libSDL2main.a(SDL_windows_main.o): In function `main_getcmdline':
/Users/slouken/release/SDL/SDL2-2.0.5-source/foo-x86/../src/main/windows/SDL_windows_main.c:153: undefined reference to `SDL_malloc'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libSDL2main.a(SDL_windows_main.o): In function `ParseCommandLine':
/Users/slouken/release/SDL/SDL2-2.0.5-source/foo-x86/../src/main/windows/SDL_windows_main.c:54: undefined reference to `SDL_isspace'
/Users/slouken/release/SDL/SDL2-2.0.5-source/foo-x86/../src/main/windows/SDL_windows_main.c:80: undefined reference to `SDL_isspace'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libSDL2main.a(SDL_windows_main.o): In function `main_utf8':
/Users/slouken/release/SDL/SDL2-2.0.5-source/foo-x86/../src/main/windows/SDL_windows_main.c:123: undefined reference to `SDL_SetMainReady'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libSDL2main.a(SDL_windows_main.o): In function `main_getcmdline':
/Users/slouken/release/SDL/SDL2-2.0.5-source/foo-x86/../src/main/windows/SDL_windows_main.c:161: undefined reference to `SDL_free'
/Users/slouken/release/SDL/SDL2-2.0.5-source/foo-x86/../src/main/windows/SDL_windows_main.c:162: undefined reference to `SDL_free'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libSDL2main.a(SDL_windows_main.o): In function `ParseCommandLine':
/Users/slouken/release/SDL/SDL2-2.0.5-source/foo-x86/../src/main/windows/SDL_windows_main.c:80: undefined reference to `SDL_isspace'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libSDL2main.a(SDL_windows_main.o): In function `OutOfMemory':
/Users/slouken/release/SDL/SDL2-2.0.5-source/foo-x86/../src/main/windows/SDL_windows_main.c:107: undefined reference to `SDL_ShowSimpleMessageBox'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libSDL2main.a(SDL_windows_main.o): In function `console_wmain':
/Users/slouken/release/SDL/SDL2-2.0.5-source/foo-x86/../src/main/windows/SDL_windows_main.c:181: undefined reference to `SDL_malloc'
/Users/slouken/release/SDL/SDL2-2.0.5-source/foo-x86/../src/main/windows/SDL_windows_main.c:185: undefined reference to `SDL_wcslen'
/Users/slouken/release/SDL/SDL2-2.0.5-source/foo-x86/../src/main/windows/SDL_windows_main.c:185: undefined reference to `SDL_iconv_string'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libSDL2main.a(SDL_windows_main.o): In function `main_utf8':
/Users/slouken/release/SDL/SDL2-2.0.5-source/foo-x86/../src/main/windows/SDL_windows_main.c:123: undefined reference to `SDL_SetMainReady'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libSDL2main.a(SDL_windows_main.o): In function `console_wmain':
/Users/slouken/release/SDL/SDL2-2.0.5-source/foo-x86/../src/main/windows/SDL_windows_main.c:192: undefined reference to `SDL_free'
collect2.exe: error: ld returned 1 exit status
Cheers and hth. - Alf
  • 142,714
  • 15
  • 209
  • 331
  • For your case, the duplicate's answer about [failure to link with relevant library or object files](https://stackoverflow.com/a/12574400/464581) is most relevant. – Cheers and hth. - Alf Sep 02 '17 at 02:40
  • Looking At The Other Article And That Does Not Cover MinGW Or SDL2, I Need To Know These Issues From MinGW using SDL2 Cause I Don't Use Or Ever Plan To Use MSVC, Nor Do I Use An IDE Anymore, I Use A Simple Text Editor With Syntax Highlighting – PokemonFanboy666 Sep 02 '17 at 03:58
  • Here's a google search for you: (https://www.google.com/search?q=link+sdl+with+mingw). Here's one relevant result in that list: (https://w3.cs.jmu.edu/bernstdh/Web/common/help/cpp_mingw-sdl-setup.php). – Cheers and hth. - Alf Sep 02 '17 at 05:37

0 Answers0