Portál AbcLinuxu, 7. května 2025 03:25
Řešení dotazu:
-static?
$ cat stat.c #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> void fnc(const char *filename) { struct stat st; stat(filename,&st); }
$ gcc -fPIC -shared -o libStat.so stat.c -static -lc $ nm -D libStat.so |grep -w stat U statAsi nestačilo.
gcc -o libtest.so test.c crt1.o libc.a -lm -lc -lgcc
Netestováno.
-static
Do not link against shared libraries. ... You may use this option multiple times on the command line: it affects library searching for -l options which follow it.
-shared
Create a shared library.
$ nm libStat.so |grep -w stat 00000000000082e0 t statDomnievam sa, že by malo byť možné na stroji A prinútiť linker vyrobiť tiež binárku, ktorá obsahuje (t)ext funkcie stat(). Taká binárka by potom fungovala na oboch systémoch. Otázka je: ako to tomu linkeru na stroji A povedať?
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.