# Linking SDL on XP

**URL:** <https://discourse.libsdl.org/t/linking-sdl-on-xp/12510>\
**Category:** SDL Development\
**Created:** [August 31, 2005, 8:01am UTC](https://discourse.libsdl.org/t/linking-sdl-on-xp/12510 "2005-08-31T08:01:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guillaume\_Denis](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/g/a8b319/32.png) [@Guillaume\_Denis](https://discourse.libsdl.org/u/Guillaume_Denis)\
**Post date:** [August 31, 2005, 8:01am UTC](https://discourse.libsdl.org/t/linking-sdl-on-xp/12510/1 "2005-08-31T08:01:25Z")

</div>

Hello,

I have tried to dynamically link SDL on Windows XP, by creating a dll  
this way :

gcc -Wall -mno-cygwin -I"c:\SDL-1.2.7\include\SDL" -L"c:\SDL-1.2.7\lib"  
-shared pad.c -lSDL -wl,-add-stdcall-alias -o pad.dll

I would like to put the dlls (SDL.dll and the created one pad.dll) in  
the working directory for simpler installation ; but if SDL.dll is not  
in C:\WINDOWS\SYSTEM32, it is not found at runtime.

How can I specify SDL.dll path ?

Thank you, Guillaume

---

<div class="post-metadata">

**Author:** ![slouken](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/ec9cab/32.png) [@slouken](https://discourse.libsdl.org/u/slouken)\
**Post date:** [September 1, 2005, 12:01am UTC](https://discourse.libsdl.org/t/linking-sdl-on-xp/12510/2 "2005-09-01T00:01:07Z")

</div>

> Hello,

> I have tried to dynamically link SDL on Windows XP, by creating a dll  
> this way :

> gcc -Wall -mno-cygwin -I"c:\SDL-1.2.7\include\SDL" -L"c:\SDL-1.2.7\lib"  
> -shared pad.c -lSDL -wl,-add-stdcall-alias -o pad.dll

You should link with SDL.dll.a, which is included in the mingw development  
library. When you link to it, your app will link and then depend on SDL.dll

See ya,  
-Sam Lantinga, Software Engineer, Blizzard Entertainment

---

<div class="post-metadata">

**Author:** ![Guillaume\_Denis](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/g/a8b319/32.png) [@Guillaume\_Denis](https://discourse.libsdl.org/u/Guillaume_Denis)\
**Post date:** [September 1, 2005, 7:30am UTC](https://discourse.libsdl.org/t/linking-sdl-on-xp/12510/3 "2005-09-01T07:30:47Z")

</div>

Sam Lantinga \<slouken [twomix.devolution.com](http://twomix.devolution.com)\> writes:

> > Hello,
> 
> > I have tried to dynamically link SDL on Windows XP, by creating a dll  
> > this way :
> 
> > gcc -Wall -mno-cygwin -I"c:\SDL-1.2.7\include\SDL" -L"c:\SDL-1.2.7\lib"  
> > -shared pad.c -lSDL -wl,-add-stdcall-alias -o pad.dll
> 
> You should link with SDL.dll.a, which is included in the mingw development  
> library. When you link to it, your app will link and then depend on SDL.dll
> 
> See ya,  
> -Sam Lantinga, Software Engineer, Blizzard Entertainment

Sam,

In fact my problem is not linking, but accessing SDL.dll at runtime in another  
directory than C:\WINDOWS\SYSTEM32

I would like to put SDL.dll in a subdirectory of my application, is it possible ?

Guillaume

---

<div class="post-metadata">

**Author:** ![Marc\_Daya](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/m/c77e96/32.png) [@Marc\_Daya](https://discourse.libsdl.org/u/Marc_Daya)\
**Post date:** [September 1, 2005, 8:46am UTC](https://discourse.libsdl.org/t/linking-sdl-on-xp/12510/4 "2005-09-01T08:46:36Z")

</div>

> Sam Lantinga \<slouken [twomix.devolution.com](http://twomix.devolution.com)\> writes:
> 
> > > Hello,
> > 
> > > I have tried to dynamically link SDL on Windows XP, by  
> > > creating a dll  
> > > this way :
> > 
> > > gcc -Wall -mno-cygwin -I"c:\SDL-1.2.7\include\SDL"  
> > > -L"c:\SDL-1.2.7\lib"  
> > > -shared pad.c -lSDL -wl,-add-stdcall-alias -o pad.dll
> > 
> > You should link with SDL.dll.a, which is included in the  
> > mingw development  
> > library. When you link to it, your app will link and then  
> > depend on SDL.dll
> > 
> > See ya,  
> > -Sam Lantinga, Software Engineer, Blizzard Entertainment
> 
> Sam,
> 
> In fact my problem is not linking, but accessing SDL.dll at  
> runtime in another  
> directory than C:\WINDOWS\SYSTEM32
> 
> I would like to put SDL.dll in a subdirectory of my  
> application, is it possible ?
> 
> Guillaume

AFAIK, when attempting to load a DLL, windows will search the current  
directory and then the directories specified in the PATH environment  
variable. if the DLL is not the same directory as your executable,  
you’ll need to have the the directory on your PATH.

does anyone know if SDL has an environment that can be used to set the  
DLL name? it is does, perhaps one could set this to ‘\dlls\SDL.dll’  
and fool windows into loading ‘.\dlls\SDL.dll’ when it tries to find  
the DLL in the current directory … ?

.marc

---

<div class="post-metadata">

**Author:** ![Guillaume\_Denis](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/g/a8b319/32.png) [@Guillaume\_Denis](https://discourse.libsdl.org/u/Guillaume_Denis)\
**Post date:** [September 5, 2005, 9:29am UTC](https://discourse.libsdl.org/t/linking-sdl-on-xp/12510/5 "2005-09-05T09:29:09Z")

</div>

Guillaume Denis \<denis [cri.ensmp.fr](http://cri.ensmp.fr)\> writes:

> Hello,
> 
> I have tried to dynamically link SDL on Windows XP, by creating a dll  
> this way :
> 
> gcc -Wall -mno-cygwin -I"c:\SDL-1.2.7\include\SDL" -L"c:\SDL-1.2.7\lib"  
> -shared pad.c -lSDL -wl,-add-stdcall-alias -o pad.dll
> 
> I would like to put the dlls (SDL.dll and the created one pad.dll) in  
> the working directory for simpler installation ; but if SDL.dll is not  
> in C:\WINDOWS\SYSTEM32, it is not found at runtime.
> 
> How can I specify SDL.dll path ?
> 
> Thank you, Guillaume

I am updating the post even if the solution I have found might concern  
few people here (Java developers).  
I am using SDL.dll from Java through the JNI this way :

System.loadLibrary(“bin/SDL”);  
System.loadLibrary(“bin/pad”);

I make no call to SDL from Java (my Java app calls pad.dll which calls SDL.dll)  
but this way I can put SDL.dll in a subdirectory of the working directory.

Guillaume
