The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Linking SDL Statically
Spirrwell


Joined: 26 Aug 2011
Posts: 9
Alright I'm not sure where the problem is, but let me start by saying I'm using the new Code::Blocks 12.11 IDE under Windows Vista.

I've tried to compile both SDL 1.2 and SDL 2.0 as well as simply trying the MinGW binaries, but this hasn't fixed my problem and it's an odd one. It's not the program I wrote myself, I'm sure about that, because I've never had a problem making simple SDL programs that create a window before under Windows 7 (or Linux) with Code::Blocks 10.05.

It's acting as though I'm getting a linker error and I'm linking SDLmain before SDL as well as linking mingw32 and etc. Basically I compiled both SDL 1.2 and 2.0 in their own directories and copied the header files as well as the libraries to C:\Program Files (x86)\CodeBlocks\MinGW\lib and C:\Program Files (x86)\CodeBlocks\MinGW\include, but my errors are acting like Code::Blocks is looking in my C:\SDLblabla folder where I compiled SDL which is weird.

Currently I'm using SDL 2.0.

Here are my build messages:

Code:
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\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'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\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'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\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'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\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'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\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'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\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'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\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'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\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'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\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'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\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'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\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'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\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'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\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'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\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'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\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'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\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'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\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'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\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'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\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'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\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) ===|


What the hell is going on?
Spirrwell


Joined: 26 Aug 2011
Posts: 9
Alright, I figured out what the problem was and that was that the dynamic libraries weren't built properly when I built SDL 2.0 and so Code::Blocks went with the static libraries. So what I want to know is how do I link SDL 2.0 statically with Code::Blocks without all of these errors?
Taiki


Joined: 02 Dec 2012
Posts: 11
Hi,
I've the same kind of issue but I want to add some details:
It compiles fine with Visual C (but not with ICC nor MinGW) and the Visual C build isn't usable by MinGW but here is it if someone want to invistigate: https://www.dropbox.com/s/cuylbh3haby5bg9/SDL.lib

The problem is to mix VC and MinGW includes, that creates a lot of conflict.
Issues start with #include <ddraw.h>, a header contained in the DirectX SDK but if you add it the the compiler path search, dependencies issue will appear and then conflicts between MinGW and VC includes (I guess) create brazillions error.
My knowledges in DirectX aren't good enough to fix it myself so, I join the Spirrwell request :X

Regards

Taiki
Linking SDL Statically
Doug
Guest

hm... I'm not sure what original thread you're referring to, but you can't mix and match.

Specifically the .lib format that VS generates isn't compatible with... anything else. Like wise, the .a and .o formats that mingw generates are not recognisable by VS. 


So if you want to statically link your binaries, you're stuck using one or the other. 


(This isn't an SDL limitation; it's a C/C++ limitation)


~
Doug.



On Mon, Feb 11, 2013 at 4:56 AM, Taiki wrote:
Quote:
Hi,
I've the same kind of issue.
I guess, as it compile fine with Visual C (but not with ICC nor MinGW) that it's due to includes.
The Visual C build isn't usable by MinGW but here is it if someone want to invistigate: https://www.dropbox.com/s/cuylbh3haby5bg9/SDL.lib

The problem of deal with VC includes and MinGW is that it creates a lot of conflict.
Issues start with #include , a header contained in the DirectX SDK but if you add it the the compiler path search, dependencies issue will appear and then conflicts between MinGW and VC includes (I guess) create brazillions error.
My knowledges in DirectX aren't good enough to fix it myself so, I join the Spirrwell request :X

Regards

Taiki


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Spirrwell


Joined: 26 Aug 2011
Posts: 9
Actually some libraries work with the .lib format even under MinGW. OpenAL for example have their binaries in .lib format, yet it still works just fine. But that's not the point here, the problem is I can't get SDL 2.0 to link statically and it's acting as though there are other dependencies not yet met like winmm, but linking to it does nothing.

Are there other libraries that need linking to? I mean I absolutely hate having to compile SDL 2.0 and what I've learned is that even with the SDL_image HG doesn't come with everything so perhaps SDL 2.0 doesn't either. I had to download libjpg, zlib, and libpng and build them to get support for those alternate file formats and I still couldn't get png files to work.

I can get SDL 2.0 to compile and link just fine both dynamically and statically under Ubuntu 12.04 64 bit. I mean it's just perfect. Is there any projection as to when Windows binaries will be available for SDL 2.0 or when SDL 2.0 will be released officially?
Linking SDL Statically
Sik


Joined: 26 Nov 2011
Posts: 905
That he mentions the includes makes me think that he imported the
Visual Studio projects (several IDEs can do this) and tried to build
it with other toolchains. When I had to do that because I couldn't
figure out the proper way to build with MinGW I went into
SDL_config_windows.h and started commenting out DirectX support until
it built. Not really much of an issue except because the only
non-DirectX audio alternative has a 500ms latency :(

2013/2/10, Doug:
Quote:
hm... I'm not sure what original thread you're referring to, but you can't
mix and match.

Specifically the .lib format that VS generates isn't compatible with...
anything else. Like wise, the .a and .o formats that mingw generates are
not recognisable by VS.

So if you want to statically link your binaries, you're stuck using one or
the other.

(This isn't an SDL limitation; it's a C/C++ limitation)

~
Doug.


On Mon, Feb 11, 2013 at 4:56 AM, Taiki wrote:

Quote:
**
Hi,
I've the same kind of issue.
I guess, as it compile fine with Visual C (but not with ICC nor MinGW)
that it's due to includes.
The Visual C build isn't usable by MinGW but here is it if someone want
to
invistigate: https://www.dropbox.com/s/cuylbh3haby5bg9/SDL.lib

The problem of deal with VC includes and MinGW is that it creates a lot
of
conflict.
Issues start with #include **, a header contained in the DirectX SDK but
if you add it the the compiler path search, dependencies issue will
appear
and then conflicts between MinGW and VC includes (I guess) create
brazillions error.
My knowledges in DirectX aren't good enough to fix it myself so, I join
the Spirrwell request :X

Regards

Taiki

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Taiki


Joined: 02 Dec 2012
Posts: 11
Thanks, it worked perfectly without Joystick, Audio and touch support (stuffs I didn't need).
Not my topic but thanks :p
Linking SDL Statically
Sik


Joined: 26 Nov 2011
Posts: 905
You can still use joysticks without DirectX if you really need later
Razz (though you miss out on things like rumble and such - but for basic
access to the input it should be enough)

2013/2/11, Taiki:
Quote:
Thanks, it worked perfectly without Joystick, Audio and touch support
(stuffs I didn't need).
Not my topic but thanks :p





_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Spirrwell


Joined: 26 Aug 2011
Posts: 9
But I'm still without a solution. Sad
Taiki


Joined: 02 Dec 2012
Posts: 11
Do you need Audio/Jostick/Touch?
If not, statically link with this .a http://www.mediafire.com/?p68hefp8z9lu9kw
Spirrwell


Joined: 26 Aug 2011
Posts: 9
Taiki wrote:
Do you need Audio/Jostick/Touch?
If not, statically link with this .a http://www.mediafire.com/?p68hefp8z9lu9kw


Two things.

1. Yes, I need Joystick support and Audio support (assuming that SDL_mixer would make no difference for Audio)

2. Is that the right version? It just says libSDL.a not libSDL2.a
Taiki


Joined: 02 Dec 2012
Posts: 11
It's built from the SDL2 source code on libsdl.org
For Joystick support, well, this build doesn't contain anything for that =/
Spirrwell


Joined: 26 Aug 2011
Posts: 9
So then how can this be fixed? I mean what's the actual issue with the code that makes it not work?
Taiki


Joined: 02 Dec 2012
Posts: 11
The problem is to include dinput.h
You can try to fix it yourself by commenting stuffs in sdl_config_windows then fix issues in things you need...