list how to do runtime linking here for different OS's
Posted: Sat Dec 09, 2006 4:18 pm
could people please list how to load an external library and use it for different OS's
by runtime linking I mean like loading a DLL(win32) or shared objects(unix)
this is my small little example type thing:
and that's all I have just win32 and a generic unix way
so please post how to do this on other OS's such as Mac, linux(heard their was a different way to do it on linux), ect..
list minority or major OS's..I just want as many as I can get
also could you please tell how to build a dynamically linkable file using gcc?
by runtime linking I mean like loading a DLL(win32) or shared objects(unix)
this is my small little example type thing:
Code: Select all
#ifdef WIN32 //this is the win32 version
#define GOOD_OS
#include <windows.h>
void *LoadExLibrary(char *name){
void *handle;
handle=LoadLibrary(name);
if(handle==NULL){
panic("Error during LoadLibrary\n");
}
return handle;
}
void *GetExSymbol(char *name,void *ExLibrary){
void *address;
address=GetProcAddress(ExLibrary,name);
return address;
}
int UnloadExLibrary(void *handle){
int error;
error=FreeLibrary(handle);
return error;
}
#endif
#ifdef UNIX //For UNIX
#define GOOD_OS
#include <dlfcn.h>
void *LoadExLibrary(char *name){
void *handle;
handle = dlopen(name, RTLD_LAZY);
if(!handle)
{
panic("Error during dlopen()\n");
return 0;
}
return handle;
}
void *GetExSymbol(char *name,void *ExLibrary){
void *address;
address = dlsym(ExLibrary, name);
return address;
}
int UnloadExLibrary(void *handle){
int error;
error = dlclose(handle);
return error;
}
#endif
and that's all I have just win32 and a generic unix way
so please post how to do this on other OS's such as Mac, linux(heard their was a different way to do it on linux), ect..
list minority or major OS's..I just want as many as I can get
also could you please tell how to build a dynamically linkable file using gcc?