je l'ai fait une bibliothèque partagée comme suit:Quand je fais une bibliothèque partagée, une erreur se produit
gcc -c output.c
gcc -shared -fPIC -o liboutput.so output.o
Lorsque output.c est le suivi, il pourrait travailler . Mais, lorsque output.c a été modifié comme suit, une erreur est survenue.
//#include "output.h"
#include <stdio.h>
int output(const char* st) {
printf("%s\n", st);
return 1+2;
}
Ce message d'erreur est:
/usr/bin/ld: output.o: relocation R_X86_64_PC32 against undefined 符号 `[email protected]@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: 最后的链结失败: 错误的值 collect2: error: ld returned 1 exit status
Je veux savoir pourquoi et comment traiter ce. Merci d'avance.
Cela pourrait fonctionner. Merci pour votre réponse sincèrement. –