Bonjour,

J'essaie de compiler un code de calcul sous forme d'une librairie .so afin de l'appeler sous Java via jni.

Je développe sous eclipse et dispose d'un makefile auto-généré. Il fonctionne très bien dans le cas d'une compilation classique et l'exécutable renvoie les bons résultats. Mais dans le cas présent "shared-library" j'ai l'erreur suivante à la compilation :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
g++ -shared -o "libtest.so"  ./sr/Axe.o ./sr/Pointe.o ./sr/Segment.o ./sr/SystRac.o  ./sol/Horizon.o ./sol/Sol.o  ./math/mathArchiSimple.o ./math/r3.o  ./main/main.o ./main/var.o  ./modele_archiSimple.o   
/usr/bin/ld: ./sr/Axe.o: relocation R_X86_64_32S against `vtable for Axe' can not be used when making a shared object; recompile with -fPIC
./sr/Axe.o: could not read symbols: Bad value
collect2: ld a retourné 1 code d'état d'exécution

J'ai donc naïvement rajouté -fPIC et obtient la même erreur en lancer le make via la console (via eclipse il ecrase les modfications) :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
building target: libtest.so
Invoking: Cross G++ Linker
g++ -fPIC -shared -o "libArchiSimple.so"  ./sr/Axe.o ./sr/Pointe.o ./sr/Segment.o ./sr/SystRac.o  ./sol/Horizon.o ./sol/Sol.o  ./math/mathArchiSimple.o ./math/r3.o  ./main/main.o ./main/var.o  ./modele_archiSimple.o   
/usr/bin/ld: ./sr/Axe.o: relocation R_X86_64_32S against `vtable for Axe' can not be used when making a shared object; recompile with -fPIC
./sr/Axe.o: could not read symbols: Bad value
collect2: ld a retourné 1 code d'état d'exécution
make: *** [libtest.so] Erreur 1
J'ai cherché sur les forum mais je reste bloqué. Est ce que quelqu'un serait susceptible de me donner des pistes ?