Hi,
I’m a beginner with SDL. I want to use an shared lib in linux, which was loaded
with SDL_LoadObject. I could load/open the lib. But if want load a function with
SDL_LoadFunction(), i didn’t get a function pointer back.
- My Lib:
#include <stdio.h>
#include <stdlib.h>
void libtest(){
printf(“libtest\n”);
}
comiled an linked with:
gcc -c -fPIC test.cpp
g++ -shared -Bdynamic test.o -o ./Debug/liblibrary_G711.so -lc
- Use in my Prog:
#include <SDL/SDL.h>
static struct {
int loaded;
void *handle;
void (*libtest) ();
} lib;
void test(){
…
if ( lib.loaded == 0 ) {
lib.handle = SDL_LoadObject(Testlib);
if ( lib.handle == NULL ) {
return -1;
}
lib.libtest = (void (*) ())SDL_LoadFunction(lib.handle, “libtest”);
if ( lib.libtest == NULL ) {
SDL_UnloadObject(lib.handle);
return -1; <---- Hi jumps always in the tree.
}
return 0;
}
…
}
Thanks for your help.
Sven