lstat?

Pavel Kankovsky peak na kerberos.troja.mff.cuni.cz
Úterý Září 22 22:47:08 CEST 1998


On Tue, 22 Sep 1998, Michal Krause wrote:

> Nevite nekdo, proc mi pri kompilaci programu na RH5.1 gcc hlasi
> undefined reference to `lstat' (resp. stat, fstat)
> ale jakmile kompiluju s -O2, tak to projde (a funguje)?

v /usr/include/sys/stat.h jsou takoveto veci

extern __inline__ int stat (__const char *__path, struct stat *__statbuf)
{ return __xstat (_STAT_VER, __path, __statbuf); }

procez program kompilovany bez optimalizaci (tj. neprovede se inline)
obsahuje odkaz na symbol stat, zatimco program kompilovany
s optimalizacemi se odkazuje na __xstat

vypada to, ze v glibc2 (kontrolovan RH 5.1 a Debian 2.0)
narozdil od libc5 nejsou "weak symbols" typu stat --> neco, takze
program bez optimalizaci ma smulu

ve FAQ je napsano

2.7.    Looking through the shared libc file I haven't found the
        functions `stat', `lstat', `fstat', and `mknod' and while
        linking on my Linux system I get error messages.  How is
        this supposed to work?
 
{RM} Believe it or not, stat and lstat (and fstat, and mknod)
are supposed to be undefined references in libc.so.6!  Your problem is
probably a missing or incorrect /usr/lib/libc.so file; note that this
is a small text file now, not a symlink to libc.so.6.  It should look
something like this:
 
GROUP ( libc.so.6 libc_nonshared.a )

Problem vznikal, kdyz byla vysledna binarka linkovana bez -lc (napriklad
to byla sdilena knihovna), pridanim -lc se to spravilo.

Po pravde receno mi pripada, ze tech par bajtu ve sdilene knihovne za to
nestalo.


--Pavel Kankovsky aka Peak  [ Boycott Microsoft--http://www.vcnet.com/bms ]
"You can't be truly paranoid unless you're sure they have already got you."




Další informace o konferenci Linux