User forums > Help
Unable to Compile a Simple Program\Linker Errors
oBFusCATed:
--- Quote from: Spirrwell on February 03, 2013, 04:02:10 pm ---What I don't understand is why the errors are showing up in files that are in my C:\SDL-2.0.0-6799 directory. All I do is copy the includes and libs to the C:\Program Files (x86)\CodeBlocks\MinGW folder to make it simpler, I've never had errors like this before.
--- End quote ---
I've told you why, but you've skipped it, so I repeat:
--- Quote from: oBFusCATed on February 03, 2013, 02:49:29 pm ---Keep in mind that static libraries don't handle dependencies, so you'll have to link you project to all libraries required by the static lib you're linking.
--- End quote ---
Please read more about linking to static libraries, because it seems you have very little knowledge about it or about linking in general. And it is not a simple matter.
Spirrwell:
--- Quote from: oBFusCATed on February 03, 2013, 04:24:08 pm ---
--- Quote from: Spirrwell on February 03, 2013, 04:02:10 pm ---What I don't understand is why the errors are showing up in files that are in my C:\SDL-2.0.0-6799 directory. All I do is copy the includes and libs to the C:\Program Files (x86)\CodeBlocks\MinGW folder to make it simpler, I've never had errors like this before.
--- End quote ---
I've told you why, but you've skipped it, so I repeat:
--- Quote from: oBFusCATed on February 03, 2013, 02:49:29 pm ---Keep in mind that static libraries don't handle dependencies, so you'll have to link you project to all libraries required by the static lib you're linking.
--- End quote ---
Please read more about linking to static libraries, because it seems you have very little knowledge about it or about linking in general. And it is not a simple matter.
--- End quote ---
And so I'll repeat, it doesn't matter whether or not I link statically or dynamically, the same errors occur. Which is why I was wondering why it was doing that. Logically if I link like normal with -lSDL2main and -lSDL2, it should do things automatically and complain about not having SDL2.dll if it's not the same directory. But it's giving me these errors which I never got under Windows 7 or Ubuntu.
I mean here it is:
It's what I've usually done in the past and stick the .dll file in the appropriate folder.
Here's the output when dynamically linking it:
--- Code: ----------------- Clean: Debug in SDL2 (compiler: GNU GCC Compiler)---------------
Cleaned "SDL2 - Debug"
-------------- Build: Debug in SDL2 (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -Wall -g -c C:\Users\Spirrwell\Documents\CodeBlocks\Projects\SDL2\Main.cpp -o obj\Debug\Main.o
mingw32-g++.exe -o bin\Debug\SDL2.exe obj\Debug\Main.o -lmingw32 -lOpenGL32 -lSDL2main -lSDL2
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../libSDL2.a(SDL_systimer.o): In function `SDL_StartTicks':
c:\SDL-2.0.0\buildsdl2/../src/timer/windows/SDL_systimer.c:59: undefined reference to `timeBeginPeriod@4'
c:\SDL-2.0.0\buildsdl2/../src/timer/windows/SDL_systimer.c:60: undefined reference to `timeGetTime@0'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../libSDL2.a(SDL_systimer.o): In function `SDL_GetTicks':
c:\SDL-2.0.0\buildsdl2/../src/timer/windows/SDL_systimer.c:85: undefined reference to `timeGetTime@0'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../libSDL2.a(SDL_windowswindow.o): In function `WIN_SetWindowGammaRamp':
c:\SDL-2.0.0\buildsdl2/../src/video/windows/SDL_windowswindow.c:511: undefined reference to `CreateDCW@16'
c:\SDL-2.0.0\buildsdl2/../src/video/windows/SDL_windowswindow.c:513: undefined reference to `SetDeviceGammaRamp@8'
c:\SDL-2.0.0\buildsdl2/../src/video/windows/SDL_windowswindow.c:517: undefined reference to `DeleteDC@4'
c:\SDL-2.0.0\buildsdl2/../src/video/windows/SDL_windowswindow.c:517: undefined reference to `DeleteDC@4'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../libSDL2.a(SDL_windowswindow.o): In function `WIN_GetWindowGammaRamp':
c:\SDL-2.0.0\buildsdl2/../src/video/windows/SDL_windowswindow.c:530: undefined reference to `CreateDCW@16'
c:\SDL-2.0.0\buildsdl2/../src/video/windows/SDL_windowswindow.c:532: undefined reference to `GetDeviceGammaRamp@8'
c:\SDL-2.0.0\buildsdl2/../src/video/windows/SDL_windowswindow.c:536: undefined reference to `DeleteDC@4'
c:\SDL-2.0.0\buildsdl2/../src/video/windows/SDL_windowswindow.c:536: undefined reference to `DeleteDC@4'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../libSDL2.a(SDL_winmm.o): In function `WINMM_CloseDevice':
c:\SDL-2.0.0\buildsdl2/../src/audio/winmm/SDL_winmm.c:166: undefined reference to `waveInClose@4'
c:\SDL-2.0.0\buildsdl2/../src/audio/winmm/SDL_winmm.c:171: undefined reference to `waveOutClose@4'
c:\SDL-2.0.0\buildsdl2/../src/audio/winmm/SDL_winmm.c:178: undefined reference to `waveOutUnprepareHeader@12'
c:\SDL-2.0.0\buildsdl2/../src/audio/winmm/SDL_winmm.c:178: undefined reference to `waveOutUnprepareHeader@12'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../libSDL2.a(SDL_winmm.o): In function `WINMM_PlayDevice':
c:\SDL-2.0.0\buildsdl2/../src/audio/winmm/SDL_winmm.c:129: undefined reference to `waveOutWrite@12'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../libSDL2.a(SDL_winmm.o): In function `DetectWaveOutDevs':
c:\SDL-2.0.0\buildsdl2/../src/audio/winmm/SDL_winmm.c:51: undefined reference to `waveOutGetNumDevs@0'
c:\SDL-2.0.0\buildsdl2/../src/audio/winmm/SDL_winmm.c:51: undefined reference to `waveOutGetDevCapsW@12'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../libSDL2.a(SDL_winmm.o): In function `DetectWaveInDevs':
c:\SDL-2.0.0\buildsdl2/../src/audio/winmm/SDL_winmm.c:52: undefined reference to `waveInGetNumDevs@0'
c:\SDL-2.0.0\buildsdl2/../src/audio/winmm/SDL_winmm.c:52: undefined reference to `waveInGetDevCapsW@12'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../libSDL2.a(SDL_winmm.o): In function `WINMM_OpenDevice':
c:\SDL-2.0.0\buildsdl2/../src/audio/winmm/SDL_winmm.c:209: undefined reference to `waveInGetNumDevs@0'
c:\SDL-2.0.0\buildsdl2/../src/audio/winmm/SDL_winmm.c:212: undefined reference to `waveInGetDevCapsW@12'
c:\SDL-2.0.0\buildsdl2/../src/audio/winmm/SDL_winmm.c:222: undefined reference to `waveOutGetNumDevs@0'
c:\SDL-2.0.0\buildsdl2/../src/audio/winmm/SDL_winmm.c:225: undefined reference to `waveOutGetDevCapsW@12'
c:\SDL-2.0.0\buildsdl2/../src/audio/winmm/SDL_winmm.c:301: undefined reference to `waveInOpen@24'
c:\SDL-2.0.0\buildsdl2/../src/audio/winmm/SDL_winmm.c:355: undefined reference to `waveOutPrepareHeader@12'
c:\SDL-2.0.0\buildsdl2/../src/audio/winmm/SDL_winmm.c:355: undefined reference to `waveOutPrepareHeader@12'
c:\SDL-2.0.0\buildsdl2/../src/audio/winmm/SDL_winmm.c:305: undefined reference to `waveOutOpen@24'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../libSDL2.a(SDL_winmm.o): In function `SetMMerror':
c:\SDL-2.0.0\buildsdl2/../src/audio/winmm/SDL_winmm.c:104: undefined reference to `waveOutGetErrorTextW@12'
c:\SDL-2.0.0\buildsdl2/../src/audio/winmm/SDL_winmm.c:104: undefined reference to `waveOutGetErrorTextW@12'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../libSDL2.a(SDL_mmjoystick.o): In function `SDL_SYS_JoystickInit':
c:\SDL-2.0.0\buildsdl2/../src/joystick/windows/SDL_mmjoystick.c:162: undefined reference to `joyGetNumDevs@0'
c:\SDL-2.0.0\buildsdl2/../src/joystick/windows/SDL_mmjoystick.c:167: undefined reference to `joyGetPosEx@8'
c:\SDL-2.0.0\buildsdl2/../src/joystick/windows/SDL_mmjoystick.c:169: undefined reference to `joyGetDevCapsW@12'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../libSDL2.a(SDL_mmjoystick.o): In function `SDL_SYS_JoystickUpdate':
c:\SDL-2.0.0\buildsdl2/../src/joystick/windows/SDL_mmjoystick.c:328: undefined reference to `joyGetPosEx@8'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../libSDL2.a(SDL_windows.o): In function `WIN_CoInitialize':
c:\SDL-2.0.0\buildsdl2/../src/core/windows/SDL_windows.c:47: undefined reference to `CoInitialize@4'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../libSDL2.a(SDL_windows.o): In function `WIN_CoUninitialize':
c:\SDL-2.0.0\buildsdl2/../src/core/windows/SDL_windows.c:61: undefined reference to `CoUninitialize@0'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../libSDL2.a(SDL_windowsopengl.o): In function `WIN_GL_ChoosePixelFormatARB':
c:\SDL-2.0.0\buildsdl2/../src/video/windows/SDL_windowsopengl.c:399: undefined reference to `ChoosePixelFormat@8'
c:\SDL-2.0.0\buildsdl2/../src/video/windows/SDL_windowsopengl.c:399: undefined reference to `SetPixelFormat@12'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../libSDL2.a(SDL_windowsopengl.o): In function `WIN_GL_SetupWindow':
c:\SDL-2.0.0\buildsdl2/../src/video/windows/SDL_windowsopengl.c:518: undefined reference to `SetPixelFormat@12'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../libSDL2.a(SDL_windowsopengl.o): In function `WIN_GL_ChoosePixelFormat':
c:\SDL-2.0.0\buildsdl2/../src/video/windows/SDL_windowsopengl.c:206: undefined reference to `DescribePixelFormat@16'
c:\SDL-2.0.0\buildsdl2/../src/video/windows/SDL_windowsopengl.c:210: undefined reference to `DescribePixelFormat@16'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../libSDL2.a(SDL_windowsopengl.o): In function `WIN_GL_SwapWindow':
c:\SDL-2.0.0\buildsdl2/../src/video/windows/SDL_windowsopengl.c:668: undefined reference to `SwapBuffers@4'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../libSDL2.a(SDL_windowsmodes.o): In function `WIN_GetDisplayMode':
c:\SDL-2.0.0\buildsdl2/../src/video/windows/SDL_windowsmodes.c:62: undefined reference to `CreateDCW@16'
c:\SDL-2.0.0\buildsdl2/../src/video/windows/SDL_windowsmodes.c:71: undefined reference to `CreateCompatibleBitmap@12'
c:\SDL-2.0.0\buildsdl2/../src/video/windows/SDL_windowsmodes.c:72: undefined reference to `GetDIBits@28'
c:\SDL-2.0.0\buildsdl2/../src/video/windows/SDL_windowsmodes.c:73: undefined reference to `GetDIBits@28'
c:\SDL-2.0.0\buildsdl2/../src/video/windows/SDL_windowsmodes.c:74: undefined reference to `DeleteObject@4'
c:\SDL-2.0.0\buildsdl2/../src/video/windows/SDL_windowsmodes.c:75: undefined reference to `DeleteDC@4'
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../libSDL2.a(SDL_windowsframebuffer.o): In function `WIN_CreateWindowFramebuffer':
c:\SDL-2.0.0\buildsdl2/../src/video/windows/SDL_windowsframebuffer.c:36: undefined reference to `DeleteDC@4'
c:\SDL-2.0.0\buildsdl2/../src/video/windows/SDL_windowsframebuffer.c:39: undefined reference to `DeleteObject@4'
Process terminated with status 1 (0 minutes, 1 seconds)
50 errors, 0 warnings (0 minutes, 1 seconds)
--- End code ---
oBFusCATed:
Using -lSDL doesn't mean you link dynamically to libSDK, but it is just the proper way to specify libraries.
What matters is what the linker finds, if it finds a static library it links to it.
So you'll have to make sure you have SDL.dlll in the folders, where the linker searches for them or otherwise you'll have to link in your project to all the libraries SDL depends on.
I'm not sure if the linker will choose the dll if there are both static and dynamic libs in the same folder.
For this you'll have to inspect the manual of gcc/ld.
Which is a pretty good idea anyway, you'll learn a lot of things (hint read what -l and -L does in the manual of GCC) :)
Spirrwell:
Alrighty, I figured it out, SDL 2.0 wasn't building the shared libraries because it was MinGW or the SDL configuration that was looking in the wrong directory for its own object files. Odd, but I got it built and it works now.
Navigation
[0] Message Index
[*] Previous page
Go to full version