Hi.
I’m doing a pluggable AI for my game, so I need to allocate and execute
functions from dynamically loaded libraries.
I know how to do that in Win32, and have the code running so far.
The problem is how to do it in Linux. I have to use dlopen() to open the
library and dlsym() to get the symbol,
but how do I know the symbol’s name? What kind of a name is the one for
Windows anyway? I found it out with depview from the Platform SDK, but I’d
rather have my function exported as “GetInformation”, since it’s the only
one like that in the dll (not overloaded or anything).
Are there conventions on how to call export functions?
How do I link a dll in Linux, anyway? I tried -shared, but that got me a
program which segfaulted.
Thanks in advance…
Pius II.
my code snippet:
#if defined(WIN32)
libraryHandle=LoadLibrary(library);
if (libraryHandle==NULL)
CON_ConOut(“Library %s not found.”,library);
GetInformation=(TGetInformation)GetProcAddress(libraryHandle,"?GetInformatio
n@@YAXPADHPAH at Z");
#elif defined(LINUX)
libraryHandle=dlopen(library,0);
GetInformation=(TGetInformation)dlsym(libraryHandle,“How’sItCalled?”);
#endif
.
.
.
#ifdef LINUX
dlclose(libraryHandle)
#endif