Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

dlopen

1 view
Skip to first unread message

fahron

unread,
Aug 31, 2005, 6:36:18 AM8/31/05
to
Trebao bih library ucitati explicitno i izgleda da imam problema sa
dlsym(...).
Kod demo alata da provjerim da li radi je:

#include <stdio.h>
#include <dlfcn.h>

int main(int argc, char **argv) {
void *handle = NULL;
int (*IsFileOffline)(const char *path) = NULL;
char *error = NULL;
int i = 5555;

printf("Getting attributes for file %s\n", argv[1]);
handle = dlopen("/opt/fse/lib/libfstools.so", RTLD_LAZY);
if(!handle) {
fputs(dlerror(), stderr);
exit(1);
}
IsFileOffline = dlsym(handle, "IsFileOffline");
if((error = dlerror()) != NULL) {
fprintf(stderr,"%s\n", error);
exit(1);
}
i = IsFileOffline(argv[2]);
printf(" IsFileOffline: dec[%d] hex[%#x]\n", i, i);
dlclose(handle);
exit(0);
}

bildam ga sa:
gcc -rdynamic -o dlopenTest dlopenTest.c -ldl

prototip funkcije u SDK header-u je:
extern "C" int IsFileOffline(const char *a_path);

IsFileOffline mi vrati pogresnu vrijednost.

Same funkcije dlopen(...) i dlsym(...) mi ne javljaju nikakvu gresku,
ali ako isti library linkam u compile time rezultat funkcije je
ispravan dok u ovom slucaju explicitnog ucitavanja nije.
Ima li neko ideju sta bi mogao biti pr
oblem?

0 new messages