Sdl.dll

Hi all!

This is probebly an esay one! I m tying to put de sdl.dll outside de main exe
root:

Bin
sdl.dll
main.exe

int main(int in_argc, char **in_argv)
{
LoadLibrary(“bin/sdl.dll”);

if (SDL_Init(SDL_INIT_VIDEO))
{
	Trace("Video initialization failed: %s\n", SDL_GetError());
	return -1;
}

SNIP…

well it doesn t work… can I do that on windows xp? any ideas???

or even better… include de sdl.dll in the main.exe?

Golgoth

THX

That should work, however, you’ll need to make sdl.dll “Delay Loaded” -
I’m not sure if you can do this with GCC (I’m guessing you can under a
different term, or by doing a collection of things) but try googling
“Delay Loaded DLL compiler” (replacing compiler with your
compiler name/version) for microsoft compilers.

Golgoth wrote:> Hi all!

This is probebly an esay one! I m tying to put de sdl.dll outside de main exe
root:

Bin
sdl.dll
main.exe

int main(int in_argc, char **in_argv)
{
LoadLibrary(“bin/sdl.dll”);

if (SDL_Init(SDL_INIT_VIDEO))
{
Trace(“Video initialization failed: %s\n”, SDL_GetError());
return -1;
}

SNIP…

well it doesn t work… can I do that on windows xp? any ideas???

or even better… include de sdl.dll in the main.exe?

Golgoth

THX


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Sorry to double reply, frogot to mention a few other options:

You can set the PATH environment variable (I think it’s path) to include
the Bin folder, or put sdl.dll into one of the many system folders -
C:\windows\system32\ or C:\winnt\system32\ would be your best bets - but
that should only be done via installer program with version checks to
make sure it isn’t replacing a newer version of the DLL.

Golgoth wrote:> Hi all!

This is probebly an esay one! I m tying to put de sdl.dll outside de main exe
root:

Bin
sdl.dll
main.exe

int main(int in_argc, char **in_argv)
{
LoadLibrary(“bin/sdl.dll”);

if (SDL_Init(SDL_INIT_VIDEO))
{
Trace(“Video initialization failed: %s\n”, SDL_GetError());
return -1;
}

SNIP…

well it doesn t work… can I do that on windows xp? any ideas???

or even better… include de sdl.dll in the main.exe?

Golgoth

THX


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

but try googling
"Delay Loaded DLL compiler" (replacing compiler with your
compiler name/version) for microsoft compilers.

hummm… I ve found this:

http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/vccore/html/vcrefdelayload(delayloadimport).asp

In the project properties: (VS .NET)-----------------------------------
Linker/General/Aditionnal Library Directories
I add:
bin

Linker/inputs/Delay Loaded DLLs
I add:
/DELAYLOAD:sdl.dll

Seams like a good plan… but doesn t work…

i also tried:

#pragma comment(linker, “/DelayLoad:sdl.dll”)

int main(int in_argc, char **in_argv)
{

if (SDL_Init(SDL_INIT_VIDEO))
{
	Trace("Video initialization failed: %s\n", SDL_GetError());
	return -1;
}

SNIP…

That will be even better… but doesnt work either…

what am I doing wrong?

THX

Golgoth

You still need the LoadLibrary line (BEFORE ANY sdl calls), if you do
have that and it isn’t working, try specifying the full path, your CWD
might be messed up - don’t froget to escape your backslashes
(“C:\PathTo\MyProgram\Bin\libsdl.dll”).

Golgoth wrote:> but try googling

“Delay Loaded DLL compiler” (replacing compiler with your
compiler name/version) for microsoft compilers.

hummm… I ve found this:

Technical documentation | Microsoft Learn
us/vccore/html/vcrefdelayload(delayloadimport).asp

In the project properties: (VS .NET)


Linker/General/Aditionnal Library Directories
I add:
bin

Linker/inputs/Delay Loaded DLLs
I add:
/DELAYLOAD:sdl.dll

Seams like a good plan… but doesn t work…

i also tried:

#pragma comment(linker, “/DelayLoad:sdl.dll”)

int main(int in_argc, char **in_argv)
{

if (SDL_Init(SDL_INIT_VIDEO))
{
Trace(“Video initialization failed: %s\n”, SDL_GetError());
return -1;
}

SNIP…

That will be even better… but doesnt work either…

what am I doing wrong?

THX

Golgoth


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Michael B. Edwin Rickert <panda industry.no-ip.com> writes:

You still need the LoadLibrary line (BEFORE ANY sdl calls), if you do
have that and it isn’t working, try specifying the full path, your CWD
might be messed up - don’t froget to escape your backslashes
(“C:\PathTo\MyProgram\Bin\libsdl.dll”).

In the project properties: (VS .NET)-----------------------------------
Linker/General/Aditionnal Library Directories
I add:
bin

Linker/inputs/Delay Loaded DLLs
I add:
sdl.dll // Not /DELAYLOAD:sdl.dll

SNIP…

int main(int in_argc, char **in_argv)
{
LoadLibrary(“C:\project\bin\sdl.dll”);

if (SDL_Init(SDL_INIT_VIDEO))
{
	Trace("Video initialization failed: %s\n", SDL_GetError());
	return -1;
}

SNIP…

… got no warnings… but crashes when execute… we must be close…

golgoth

Check to make sure LoadLibrary isn’t returning NULL (indicating an
error). If it does, check GetLastError to see if that provides anything
useful… example code for getting a string value can be found on MSDN:

If that dosn’t help, can you track down with your debugger where it’s
crashing?

Golgoth wrote:> Michael B. Edwin Rickert <panda industry.no-ip.com> writes:

You still need the LoadLibrary line (BEFORE ANY sdl calls), if you do
have that and it isn’t working, try specifying the full path, your CWD
might be messed up - don’t froget to escape your backslashes
(“C:\PathTo\MyProgram\Bin\libsdl.dll”).

In the project properties: (VS .NET)


Linker/General/Aditionnal Library Directories
I add:
bin

Linker/inputs/Delay Loaded DLLs
I add:
sdl.dll // Not /DELAYLOAD:sdl.dll

SNIP…

int main(int in_argc, char **in_argv)
{
LoadLibrary(“C:\project\bin\sdl.dll”);

if (SDL_Init(SDL_INIT_VIDEO))
{
Trace(“Video initialization failed: %s\n”, SDL_GetError());
return -1;
}

SNIP…

… got no warnings… but crashes when execute… we must be close…

golgoth


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Michael B. Edwin Rickert <panda industry.no-ip.com> writes:

Check to make sure LoadLibrary isn’t returning NULL (indicating an
error). If it does, check GetLastError to see if that provides anything
useful… example code for getting a string value can be found on MSDN:

it crash before entering:

SNIP…
int main(int in_argc, char **in_argv)
{
SNIP…

it called:
main.exe!__tailMerge_SDL() + 0xd Unknown
then:
delayLoadHelper2(const ImgDelayDescr * pidd=0x0000004c, int (void)* *
ppfnIATEntry=0x0012fe4c) Line 269 C++

then crash in
crtexe.c
kernel32.dll!77e73887()

at the end of:

GetModuleHandleA(NULL),
NULL,
lpszCommandLine,
StartupInfo.dwFlags & STARTF_USESHOWWINDOW
? StartupInfo.wShowWindow
: SW_SHOWDEFAULT
);

Im totaly lost here!!! looks like it ask for an SDL call before…
LoadLibrary(“G:\AX6\bin\sdl.dll”);

any ideas??? thx for your help!

Golgoth

… well I finaly figured it out…

LoadLibrary(“bin\sdl.dll”); is case sensitive…

LoadLibrary(“bin\SDL.dll”); works fine

Doh!!

THX

Golgoth <neosettlers sympatico.ca> writes:

… well I finaly figured it out…

LoadLibrary(“bin\sdl.dll”); is case sensitive…

LoadLibrary(“bin\SDL.dll”); works fine

Doh!!

THX

false alert… the case sensitive works fine for the fmod.dll … so i figured
it will for the SDL.dll… well back to the crash… anyone ever tried this to
Delay loaded sdl.dll!?!?!

I think I need some sleep…

Golgoth

Hmm, doublecheck that it is indeed crashing before it enters main
(std::cerr << “main entered” << std::endl;)
If it is, I’m guessing it has something to do with a pragma passed in
the headers which you may need to disable - or you may need to call
LoadLibraryEx to handle this somehow.

Do you really need sdl.dll in a different folder?

Golgoth wrote:> false alert… the case sensitive works fine for the fmod.dll … so i figured

it will for the SDL.dll… well back to the crash… anyone ever tried this to
Delay loaded sdl.dll!?!?!

I think I need some sleep…

Golgoth

Golgoth wrote:

it crash before entering:

SNIP…
int main(int in_argc, char **in_argv)
{
SNIP…

I believe SDL defines its own main() and WinMain() functions under Windows, and uses a #define to rename yours to SDL_main.
This is then called from within the SDL functions, which perform certain bits of initialisation, presumably ones which have to go before anything done by the program. These functions require the SDL library to be loaded.

I’m not entirely sure about this, but I think it might be possible to override SDL’s WinMain() function with your own, which could properly load the library before doing the normal initialisation. Look in src/main/win32/SDL_win32_main.c within the SDL source directory to see what goes on in the SDL functions.

Chris E.
-------------- next part --------------
A non-text attachment was scrubbed…
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040926/208b306a/attachment.pgp

Chris E. <chrise chrise.tk> writes:

I think it might be possible to override SDL’s WinMain() function with
your own, which could properly load the library before doing the normal
initialisation. Look in src/main/win32/SDL_win32_main.c within the SDL source
directory to see what goes on in the SDL functions.

anyone have any ideas about that?

dont know if you can override it but if i remember correctly that file is
public domain so hack away at it if you want to change it (:> ----- Original Message -----

From: neosettlers@sympatico.ca (Golgoth)
To:
Sent: Sunday, September 26, 2004 3:31 PM
Subject: [SDL] Re: sdl.dll

Chris E. <chrise chrise.tk> writes:

I think it might be possible to override SDL’s WinMain() function with
your own, which could properly load the library before doing the normal
initialisation. Look in src/main/win32/SDL_win32_main.c within the SDL
source
directory to see what goes on in the SDL functions.

anyone have any ideas about that?


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Alan Wolfe wrote:

dont know if you can override it but if i remember correctly that file is
public domain so hack away at it if you want to change it (:

IANAL, but I believe public domain refers to works now out of copyright,
and thus modifyable/useable in any way, by anybody, without any
restrictions. This is NOT the case with SDL (there IS a licence for it -
the LGPL I believe if I remember right) - but you do have a point in
that SDL is indeed entirely modifyable (and the source is downloadable
on libsdl.org).

It should be a simple process of renaming main/WinMain (to say, sdl_main
and sdl_WinMain), writing the your main/WinMain function as normal, and
then undefining main/WinMain and writing a second main/WinMain function
with the LoadLibrary call, and a call to the corresponding
sdl_main/sdl_WinMain function.

Aka:
#include “SDL.h”

#pragma (libs,“SDL.dll”) //the modified version of the SDL dll

int main ( int argc , char ** argv )
{
SDL_Init( SDL_INIT_VIDEO );
//…
}

//…etc etc etc…

#undef main

int main ( int argc , char ** argv )
{
LoadLibrary(“…\SDL.dll”);
return sdl_main( argc , argv ); //sdl_main exported by SDL.dll
}

Chris E. <chrise chrise.tk> writes:

I think it might be possible to override SDL’s WinMain() function with
your own, which could properly load the library before doing the normal
initialisation. Look in src/main/win32/SDL_win32_main.c within the SDL
source
directory to see what goes on in the SDL functions.

anyone have any ideas about that?

Yes. there’s a big problem with mucking around the insides of
undocumented parts of any program / program component / library. SDL
may change some of its internals around without notice and your game
will be incompatible with future versions of SDL. While this is still
LEGAL to do, it’s rather contrary to the spirit of the LGPL, which is
greatly in favor of letting anyone rather painless link your
application to any other SDL library they please.On Sep 26, 2004, at 6:31 PM, Golgoth wrote:

Donny Viszneki <smirk thebuicksix.com> writes:

Yes. there’s a big problem with mucking around the insides of
undocumented parts of any program / program component / library. SDL
may change some of its internals around without notice and your game
will be incompatible with future versions of SDL. While this is still
LEGAL to do, it’s rather contrary to the spirit of the LGPL, which is
greatly in favor of letting anyone rather painless link your
application to any other SDL library they please.

the main point was to have our game.exe the only file in the root folder…
plus a game data folder and a bin folder for dlls… so far… SDL.dll just
wont allow me to complete my mission without involving the word legal… I
didnt thought it will be that complicate to do (it seamed) a simple
procedure… well, i ll leave it as is for now… but i m still looking to
stick to the plan… nothing but the exe should be visible for the users in the
root folder… I d rather say moving it then hidding it now…

THX everyone!

Golgoth

I don’t know what your problem is. Just put a shortcut on the desktop
and/or on the start menu.On Sep 26, 2004, at 9:46 PM, Golgoth wrote:

Donny Viszneki <smirk thebuicksix.com> writes:

Yes. there’s a big problem with mucking around the insides of
undocumented parts of any program / program component / library. SDL
may change some of its internals around without notice and your game
will be incompatible with future versions of SDL. While this is still
LEGAL to do, it’s rather contrary to the spirit of the LGPL, which is
greatly in favor of letting anyone rather painless link your
application to any other SDL library they please.

the main point was to have our game.exe the only file in the root
folder…
plus a game data folder and a bin folder for dlls… so far… SDL.dll
just
wont allow me to complete my mission without involving the word
legal… I
didnt thought it will be that complicate to do (it seamed) a simple
procedure… well, i ll leave it as is for now… but i m still
looking to
stick to the plan… nothing but the exe should be visible for the
users in the
root folder… I d rather say moving it then hidding it now…

THX everyone!

Golgoth


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Yes. there’s a big problem with mucking around the insides of undocumented
parts of any program / program component / library. SDL may change some of
its internals around without notice and your game will be incompatible with
future versions of SDL. While this is still LEGAL to do, it’s rather contrary
to the spirit of the LGPL, which is greatly in favor of letting anyone rather
painless link your application to any other SDL library they please.

One thing worth noting, though, is that the sdl_main routine is statically
linked into the binary in any case. Thus, if the internals which sdl_main
uses are changed, the executable has to be relinked in any case, although
a mere relinking is enough. If you try to build a modified sdl_main
routine of your own, it has to be modified accordingly and recompiled, of
course.

// MartinOn Sun, 26 Sep 2004, Donny Viszneki wrote: