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”);
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”);
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.
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”);
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”);
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++
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!?!?!
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!?!?!
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.
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.
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.
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
}
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:
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…
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…
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.