i write a game that has some settings and data in a loadable
library.
On Linux i create a shared object:
gcc -Wl,-Bdynamic -Wl,-shared -o skin skindata.o -lc
On Win32 i do it like this:
link /dll /nologo /subsystem:console /incremental:no
/machine:I386 /map:skin.map /out:skin.dll skindata.o
On Linux i have to load it like this:
skin = SDL_LoadObject("/absolute/path/to/skin");
On Win32 i load:
skin = SDL_LoadObject(“skin.dll”);
Until here, both work fine.
sfptr = (skin_info_get_fptr)SDL_LoadFunction(skin, “skin_info_get”);
if(sfptr == NULL) {
printf(“could not get skin data address\n”);
exit(-1);
}
On Linux the part above works fine, on Win32 it fails. In the skin.map
i see that the symbol “_skin_info_get” is contained in the dll.
I also tried to load with preceding underscore, but that also failed.
Can anybody tell me why it fails on Win32?
Is there a way on Linux to NOT use an absolute path?
i write a game that has some settings and data in a loadable
library.
On Linux i create a shared object:
gcc -Wl,-Bdynamic -Wl,-shared -o skin skindata.o -lc
On Win32 i do it like this:
link /dll /nologo /subsystem:console /incremental:no
/machine:I386 /map:skin.map /out:skin.dll skindata.o
On Linux i have to load it like this:
skin = SDL_LoadObject("/absolute/path/to/skin");
On Win32 i load:
skin = SDL_LoadObject(“skin.dll”);
Until here, both work fine.
sfptr = (skin_info_get_fptr)SDL_LoadFunction(skin, “skin_info_get”);
if(sfptr == NULL) {
printf(“could not get skin data address\n”);
exit(-1);
}
On Linux the part above works fine, on Win32 it fails. In the skin.map
i see that the symbol “_skin_info_get” is contained in the dll.
I also tried to load with preceding underscore, but that also failed.
Can anybody tell me why it fails on Win32?
Is there a way on Linux to NOT use an absolute path?
Glad it helped, wish I could help more on your other problem :P> ----- Original Message -----
From: sdl-bounces+atrix2=cox.net@libsdl.org
[mailto:sdl-bounces+atrix2=cox.net at libsdl.org] On Behalf Of Torsten Mohr
Sent: Wednesday, May 03, 2006 3:22 PM
To: A list for developers using the SDL library. (includes SDL-announce)
Subject: Re: [SDL] SDL_LoadLibrary, Win32 and Linux
You need to explicitly list the symbols that are exported in a Windows
DLL (this is actually a feature, but it’s different than the current
Linux behaviour, if you don’t count gcc’s new -fvisibility command line).
You probably have:
extern SkinInfo *skin_info_get(void);
You need something more like this:
extern “C” { // (If using C++, you need this or the symbol is mangled.)
extern __declspec(dllexport) SkinInfo *skin_info_get(void);
}
This tells Windows that this symbol needs to be exported from the DLL.
Otherwise it won’t be visible at link time, or from LoadLibrary().
Look at DECLSPEC in the SDL headers for an example of abstracting this,
since SDL on Windows obviously needs this functionality itself. gcc4 has
a similar mechanism, but at this point, most Linux libraries have every
symbol that isn’t flagged “static” as exported, which is why this works
there.
Is there a way on Linux to NOT use an absolute path?
Use a relative one. Using none goes through a couple of
well-defined paths (see the manpage for dlopen(3) for the list).
You need to explicitly list the symbols that are exported in a Windows
DLL (this is actually a feature, but it’s different than the current
Linux behaviour, if you don’t count gcc’s new -fvisibility command line).
You probably have:
extern SkinInfo *skin_info_get(void);
You need something more like this:
extern “C” { // (If using C++, you need this or the symbol is mangled.)
extern __declspec(dllexport) SkinInfo *skin_info_get(void);
}
thanks a lot for that info. That was exactly the problem.