Salut,
j'ai une librairie .so et j'essaye de faire un appel à une fonction qui existe dans ce .so.
voilà mon code ;
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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);
l'erreur qui m'affiche c'est: " ‘fonc’ cannot be used as a function "
et voilà mon fonction dans le fichier .h (qui existe dans le .so):
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 
 
#ifdef __cplusplus
extern "C" {
#endif
 
int processData(char const * var1, int const var2,	int const var3, int const var4,int const var5, int const var6,int const var7, int const var8,int const var9,float const & var10);
 
#ifdef __cplusplus
}
#endif
franchement j'ai essayé plusieurs syntaxe mais g pas réussi à trouver le bon, en fait moi je travaille avec JAVA mais g besoin d'utiliser une librairie .so developpée en c++ dans mon code.