Need help to install SDL2 with the CodeBlocks IDE

Hello,

Can someone help me to setup SDL2 with CodeBlocks? I need to know how to configure my compiler and linker settings, it seems to detect all my includes paths but when I compile here’s the message I got:

||=== Build: Debug in Test_SDL2 (compiler: GNU GCC Compiler) ===|
obj\Debug\main.o||In function ZN9InitErrorC2Ev':| D:\C++ projects\Test_SDL2\main.cpp|18|undefined reference toSDL_GetError’|
obj\Debug\main.o||In function ZN3SDLC2Ej':| D:\C++ projects\Test_SDL2\main.cpp|49|undefined reference toSDL_Init’|
D:\C++ projects\Test_SDL2\main.cpp|52|undefined reference to SDL_CreateWindowAndRenderer'| obj\Debug\main.o||In functionZN3SDLD2Ev’:expressionless:
D:\C++ projects\Test_SDL2\main.cpp|59|undefined reference to SDL_DestroyWindow'| D:\C++ projects\Test_SDL2\main.cpp|60|undefined reference toSDL_DestroyRenderer’|
D:\C++ projects\Test_SDL2\main.cpp|61|undefined reference to SDL_Quit'| obj\Debug\main.o||In functionZN3SDL4drawEv’:expressionless:
D:\C++ projects\Test_SDL2\main.cpp|67|undefined reference to SDL_SetRenderDrawColor'| D:\C++ projects\Test_SDL2\main.cpp|68|undefined reference toSDL_RenderClear’|
D:\C++ projects\Test_SDL2\main.cpp|71|undefined reference to SDL_RenderPresent'| D:\C++ projects\Test_SDL2\main.cpp|89|undefined reference toSDL_SetRenderDrawColor’|
D:\C++ projects\Test_SDL2\main.cpp|90|undefined reference to SDL_RenderFillRect'| D:\C++ projects\Test_SDL2\main.cpp|91|undefined reference toSDL_RenderPresent’|
D:\C++ projects\Test_SDL2\main.cpp|92|undefined reference to SDL_Delay'| D:\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\5.1.0\..\..\..\libmingw32.a(main.o):main.c:(.text.startup+0xa7)||undefined reference toWinMain@16’|
||error: ld returned 1 exit status|
||=== Build failed: 15 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

What should I do about this???

Thank you at advance for your help,

Marc

The bane of programming in C\C++, you need to add the libraries you want linked to your program to get it to compile. You’ll need to first compile or use a pre-compiled SDL2 library and add the following options to: Project Build Options > Linker settings > Link libraries:

mingw32
SDL2
SDL2main
user32
gdi32
winmm
imm32
winspool
shell32
ole32
oleaut32
version
uuid
comdlg32
advapi32

Linking with Code:Blocks