Alright, I recently downgraded back to Vista from 7, (alright, laugh it up) and I installed Code::Blocks 12.11. Now I have had absolutely no problems in the past and all I have is a simple SDL 2.0 program that initializes SDL and quits. I've linked to the appropriate SDL2main and SDL2 libraries, (in the proper order) and it just refuses to compile and I get some odd linker errors. I even tried downloading the latest of MinGW and that didn't work. I've read up on the problem and people keep saying to link to winmm which I've never had to do, but it doesn't work anyway. I'll also mention that this happens regardless of whether I use SDL 2.0 or SDL 1.2. This also happens with other libraries as well. I get those classic "undefined reference to BLABLA" errors.
I don't have any of these problems when doing the same on Ubuntu 12.04 64 bit. It just works so well, but I can't just develop for Linux. (well I could, but that limits my options)
Just for the sake of things, here's my code:
#include <SDL.h>
int main(int argc, char* argv[])
{
if (SDL_Init(SDL_INIT_EVERYTHING) == -1)
{
printf("%s\n", SDL_GetError);
exit(EXIT_FAILURE);
}
atexit(SDL_Quit);
return 0;
}
And here's all of my build messages:
||=== SDL2, Debug ===|
..\..\..\..\..\..\Program Files (x86)\CodeBlocks\MinGW\lib\libSDL2.a(SDL_systimer.o)||In function `SDL_StartTicks':|
c:\SDL-2.0.0-6799\src\timer\windows\SDL_systimer.c|59|undefined reference to `timeBeginPeriod@4'|
c:\SDL-2.0.0-6799\src\timer\windows\SDL_systimer.c|60|undefined reference to `timeGetTime@0'|
..\..\..\..\..\..\Program Files (x86)\CodeBlocks\MinGW\lib\libSDL2.a(SDL_systimer.o)||In function `SDL_GetTicks':|
c:\SDL-2.0.0-6799\src\timer\windows\SDL_systimer.c|85|undefined reference to `timeGetTime@0'|
..\..\..\..\..\..\Program Files (x86)\CodeBlocks\MinGW\lib\libSDL2.a(SDL_windowswindow.o)||In function `WIN_SetWindowGammaRamp':|
c:\SDL-2.0.0-6799\src\video\windows\SDL_windowswindow.c|511|undefined reference to `CreateDCW@16'|
c:\SDL-2.0.0-6799\src\video\windows\SDL_windowswindow.c|513|undefined reference to `SetDeviceGammaRamp@8'|
c:\SDL-2.0.0-6799\src\video\windows\SDL_windowswindow.c|517|undefined reference to `DeleteDC@4'|
c:\SDL-2.0.0-6799\src\video\windows\SDL_windowswindow.c|517|undefined reference to `DeleteDC@4'|
..\..\..\..\..\..\Program Files (x86)\CodeBlocks\MinGW\lib\libSDL2.a(SDL_windowswindow.o)||In function `WIN_GetWindowGammaRamp':|
c:\SDL-2.0.0-6799\src\video\windows\SDL_windowswindow.c|530|undefined reference to `CreateDCW@16'|
c:\SDL-2.0.0-6799\src\video\windows\SDL_windowswindow.c|532|undefined reference to `GetDeviceGammaRamp@8'|
c:\SDL-2.0.0-6799\src\video\windows\SDL_windowswindow.c|536|undefined reference to `DeleteDC@4'|
c:\SDL-2.0.0-6799\src\video\windows\SDL_windowswindow.c|536|undefined reference to `DeleteDC@4'|
..\..\..\..\..\..\Program Files (x86)\CodeBlocks\MinGW\lib\libSDL2.a(SDL_winmm.o)||In function `WINMM_CloseDevice':|
c:\SDL-2.0.0-6799\src\audio\winmm\SDL_winmm.c|166|undefined reference to `waveInClose@4'|
c:\SDL-2.0.0-6799\src\audio\winmm\SDL_winmm.c|171|undefined reference to `waveOutClose@4'|
c:\SDL-2.0.0-6799\src\audio\winmm\SDL_winmm.c|178|undefined reference to `waveOutUnprepareHeader@12'|
c:\SDL-2.0.0-6799\src\audio\winmm\SDL_winmm.c|178|undefined reference to `waveOutUnprepareHeader@12'|
..\..\..\..\..\..\Program Files (x86)\CodeBlocks\MinGW\lib\libSDL2.a(SDL_winmm.o)||In function `WINMM_PlayDevice':|
c:\SDL-2.0.0-6799\src\audio\winmm\SDL_winmm.c|129|undefined reference to `waveOutWrite@12'|
..\..\..\..\..\..\Program Files (x86)\CodeBlocks\MinGW\lib\libSDL2.a(SDL_winmm.o)||In function `DetectWaveOutDevs':|
c:\SDL-2.0.0-6799\src\audio\winmm\SDL_winmm.c|51|undefined reference to `waveOutGetNumDevs@0'|
c:\SDL-2.0.0-6799\src\audio\winmm\SDL_winmm.c|51|undefined reference to `waveOutGetDevCapsW@12'|
..\..\..\..\..\..\Program Files (x86)\CodeBlocks\MinGW\lib\libSDL2.a(SDL_winmm.o)||In function `DetectWaveInDevs':|
c:\SDL-2.0.0-6799\src\audio\winmm\SDL_winmm.c|52|undefined reference to `waveInGetNumDevs@0'|
c:\SDL-2.0.0-6799\src\audio\winmm\SDL_winmm.c|52|undefined reference to `waveInGetDevCapsW@12'|
..\..\..\..\..\..\Program Files (x86)\CodeBlocks\MinGW\lib\libSDL2.a(SDL_winmm.o)||In function `WINMM_OpenDevice':|
c:\SDL-2.0.0-6799\src\audio\winmm\SDL_winmm.c|209|undefined reference to `waveInGetNumDevs@0'|
c:\SDL-2.0.0-6799\src\audio\winmm\SDL_winmm.c|212|undefined reference to `waveInGetDevCapsW@12'|
c:\SDL-2.0.0-6799\src\audio\winmm\SDL_winmm.c|222|undefined reference to `waveOutGetNumDevs@0'|
c:\SDL-2.0.0-6799\src\audio\winmm\SDL_winmm.c|225|undefined reference to `waveOutGetDevCapsW@12'|
c:\SDL-2.0.0-6799\src\audio\winmm\SDL_winmm.c|301|undefined reference to `waveInOpen@24'|
c:\SDL-2.0.0-6799\src\audio\winmm\SDL_winmm.c|355|undefined reference to `waveOutPrepareHeader@12'|
c:\SDL-2.0.0-6799\src\audio\winmm\SDL_winmm.c|355|undefined reference to `waveOutPrepareHeader@12'|
c:\SDL-2.0.0-6799\src\audio\winmm\SDL_winmm.c|305|undefined reference to `waveOutOpen@24'|
..\..\..\..\..\..\Program Files (x86)\CodeBlocks\MinGW\lib\libSDL2.a(SDL_winmm.o)||In function `SetMMerror':|
c:\SDL-2.0.0-6799\src\audio\winmm\SDL_winmm.c|104|undefined reference to `waveOutGetErrorTextW@12'|
c:\SDL-2.0.0-6799\src\audio\winmm\SDL_winmm.c|104|undefined reference to `waveOutGetErrorTextW@12'|
..\..\..\..\..\..\Program Files (x86)\CodeBlocks\MinGW\lib\libSDL2.a(SDL_mmjoystick.o)||In function `SDL_SYS_JoystickInit':|
c:\SDL-2.0.0-6799\src\joystick\windows\SDL_mmjoystick.c|162|undefined reference to `joyGetNumDevs@0'|
c:\SDL-2.0.0-6799\src\joystick\windows\SDL_mmjoystick.c|167|undefined reference to `joyGetPosEx@8'|
c:\SDL-2.0.0-6799\src\joystick\windows\SDL_mmjoystick.c|169|undefined reference to `joyGetDevCapsW@12'|
..\..\..\..\..\..\Program Files (x86)\CodeBlocks\MinGW\lib\libSDL2.a(SDL_mmjoystick.o)||In function `SDL_SYS_JoystickUpdate':|
c:\SDL-2.0.0-6799\src\joystick\windows\SDL_mmjoystick.c|328|undefined reference to `joyGetPosEx@8'|
..\..\..\..\..\..\Program Files (x86)\CodeBlocks\MinGW\lib\libSDL2.a(SDL_windows.o)||In function `WIN_CoInitialize':|
c:\SDL-2.0.0-6799\src\core\windows\SDL_windows.c|47|undefined reference to `CoInitialize@4'|
..\..\..\..\..\..\Program Files (x86)\CodeBlocks\MinGW\lib\libSDL2.a(SDL_windows.o)||In function `WIN_CoUninitialize':|
c:\SDL-2.0.0-6799\src\core\windows\SDL_windows.c|61|undefined reference to `CoUninitialize@0'|
..\..\..\..\..\..\Program Files (x86)\CodeBlocks\MinGW\lib\libSDL2.a(SDL_windowsopengl.o)||In function `WIN_GL_ChoosePixelFormatARB':|
c:\SDL-2.0.0-6799\src\video\windows\SDL_windowsopengl.c|399|undefined reference to `ChoosePixelFormat@8'|
c:\SDL-2.0.0-6799\src\video\windows\SDL_windowsopengl.c|399|undefined reference to `SetPixelFormat@12'|
..\..\..\..\..\..\Program Files (x86)\CodeBlocks\MinGW\lib\libSDL2.a(SDL_windowsopengl.o)||In function `WIN_GL_SetupWindow':|
c:\SDL-2.0.0-6799\src\video\windows\SDL_windowsopengl.c|518|undefined reference to `SetPixelFormat@12'|
..\..\..\..\..\..\Program Files (x86)\CodeBlocks\MinGW\lib\libSDL2.a(SDL_windowsopengl.o)||In function `WIN_GL_ChoosePixelFormat':|
c:\SDL-2.0.0-6799\src\video\windows\SDL_windowsopengl.c|206|undefined reference to `DescribePixelFormat@16'|
c:\SDL-2.0.0-6799\src\video\windows\SDL_windowsopengl.c|210|undefined reference to `DescribePixelFormat@16'|
..\..\..\..\..\..\Program Files (x86)\CodeBlocks\MinGW\lib\libSDL2.a(SDL_windowsopengl.o)||In function `WIN_GL_SwapWindow':|
c:\SDL-2.0.0-6799\src\video\windows\SDL_windowsopengl.c|668|undefined reference to `SwapBuffers@4'|
..\..\..\..\..\..\Program Files (x86)\CodeBlocks\MinGW\lib\libSDL2.a(SDL_windowsmodes.o)||In function `WIN_GetDisplayMode':|
c:\SDL-2.0.0-6799\src\video\windows\SDL_windowsmodes.c|62|undefined reference to `CreateDCW@16'|
c:\SDL-2.0.0-6799\src\video\windows\SDL_windowsmodes.c|71|undefined reference to `CreateCompatibleBitmap@12'|
c:\SDL-2.0.0-6799\src\video\windows\SDL_windowsmodes.c|72|undefined reference to `GetDIBits@28'|
c:\SDL-2.0.0-6799\src\video\windows\SDL_windowsmodes.c|73|undefined reference to `GetDIBits@28'|
c:\SDL-2.0.0-6799\src\video\windows\SDL_windowsmodes.c|74|undefined reference to `DeleteObject@4'|
c:\SDL-2.0.0-6799\src\video\windows\SDL_windowsmodes.c|75|undefined reference to `DeleteDC@4'|
..\..\..\..\..\..\Program Files (x86)\CodeBlocks\MinGW\lib\libSDL2.a(SDL_windowsframebuffer.o)||In function `WIN_CreateWindowFramebuffer':|
c:\SDL-2.0.0-6799\src\video\windows\SDL_windowsframebuffer.c|36|undefined reference to `DeleteDC@4'|
c:\SDL-2.0.0-6799\src\video\windows\SDL_windowsframebuffer.c|39|undefined reference to `DeleteObject@4'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 0 warnings (0 minutes, 1 seconds) ===|
I've asked on other forums thinking that it's a problem with SDL, but I've tried other libraries and they seem to get their own linker errors as well. I did a quick browse through the forums and didn't find anything that helped. If there's some log file that I'm supposed to post to go with this, sorry I just got here and this is bugging the heck out of me.
Also I am aware of rule number two:
2. Compiler/Linker errors are NOT Code::Blocks errors. Usually, C++ newcomers tend to confuse the Editor/IDE (Code::Blocks) with the Compiler (MINGW / GCC). You may see some errors in the compiler output because you missed to do something right in your code. But that's not Code::Blocks troubleshooting, that's C++ troubleshooting and does not belong in here. If your program doesn't compile, READ THE C++ MANUAL.
This problem seems to be Code::Blocks specific, and perhaps there's a setting that isn't quite right, but I've just done exactly what I've done in the past and for whatever reason I'm having this problem.
Well, any help is greatly appreciated!