1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
cout << "Opening hello.so...\n";
void* handle = dlopen("./lib.so", RTLD_LAZY);
if (!handle) {
cerr << "Cannot open library: " << dlerror() << '\n';
return 1;
}
// load the symbol
cout << "Loading symbol Data...\n";
char const *nativeString ="/root/Desktop/dll/testLib";
int const v1=1,v2=1,v3=1,v4=1,v5=1,v6=1,v7=1,v8=1;
float const v9=1;
typedef int(*function_t)(char const *,int const,int const,int const,int const,int const,int const,int const,int const,float const &);
function_t* fonc = (function_t*)dlsym(handle, "myFunction");
// reset errors
const char *dlsym_error = dlerror();
if (dlsym_error) {
cerr << "Cannot load symbol 'Data': " << dlsym_error <<
'\n';
dlclose(handle);
return 1;
}
cout << "Calling myFunction...\n";
fonc(nativeString,v1,v2,v3,v4,v5,v6,v7,v8,v9);
// close the library
cout << "Closing library...\n";
dlclose(handle); |
Partager