glibc2 and 'stat'

glibc2 and 'stat'

Post by Rudolf Leitg » Wed, 03 Sep 1997 04:00:00






>> I've seen just a few references to this problem: when
>> compiling under using glibc2 (in my case 2.0.5, with
>> gcc 2.7.2.3) make fails with "undefined reference to
>> 'stat'".  The glibc FAQ suggests this reflects a bad
>> or missing /usr/lib/libc.so script -- but I've checked
>> and mine is just as prescribed.  Any suggestions anyone?
>> TIA.

Maybe you still have /lib/libc.so being a symlink to glibc ?

Rudi

--

         | | | | |
       \   _____   /      
          /     \                      B O R N
      -- | o   o |  --                   T O
      -- |       |  --                S L E E P
      -- | \___/ |  --                   I N
          \_____/                   T H E   S U N
        /          \    
         | | | | |

 
 
 

glibc2 and 'stat'

Post by Allin Cottrel » Wed, 03 Sep 1997 04:00:00


I've seen just a few references to this problem: when
compiling under using glibc2 (in my case 2.0.5, with
gcc 2.7.2.3) make fails with "undefined reference to
'stat'".  The glibc FAQ suggests this reflects a bad
or missing /usr/lib/libc.so script -- but I've checked
and mine is just as prescribed.  Any suggestions anyone?
TIA.

--
Allin Cottrell
Department of Economics
Wake Forest University, NC

 
 
 

glibc2 and 'stat'

Post by Frank Sweetse » Wed, 03 Sep 1997 04:00:00



> I've seen just a few references to this problem: when
> compiling under using glibc2 (in my case 2.0.5, with
> gcc 2.7.2.3) make fails with "undefined reference to
> 'stat'".  The glibc FAQ suggests this reflects a bad
> or missing /usr/lib/libc.so script -- but I've checked
> and mine is just as prescribed.  Any suggestions anyone?
> TIA.

For some reason which is beyond me, stat and several other related calls
are not in the shared libs, only in the static libs.  So, compiling with
-static should solve the problem.

--
Frank Sweetser rasmusin at wpi.edu fsweetser at blee.net | PGP key available
paramount.res.wpi.edu RedHat Linux 2.0.31pre7 i486       | at public servers
DOS: n., A small annoying boot virus that causes random spontaneous system
     crashes, usually just before saving a massive project.  Easily cured by
     UNIX.  See also MS-DOS, IBM-DOS, DR-DOS.
(from David Vicker's .plan)

 
 
 

glibc2 and 'stat'

Post by Richard Cr » Thu, 04 Sep 1997 04:00:00


 : I've seen just a few references to this problem: when
 : compiling under using glibc2 (in my case 2.0.5, with
 : gcc 2.7.2.3) make fails with "undefined reference to
 : 'stat'".  The glibc FAQ suggests this reflects a bad
 : or missing /usr/lib/libc.so script -- but I've checked
 : and mine is just as prescribed.  Any suggestions anyone?

 This really *should* be in the FAQ; it turns up frequently enough.

 The real 'stat' and 'lstat' are buried somewhere in the the
 *static* lib. So one of several things might be wrong here:

 1) You did something really smart, like removing libc.a to save
 space (or compressing it -- ld still won't find it). If so, restore it,
 and write "I will not remove essential system binaries" 100 times.

 2) You didn't compile with optimization. 'stat' and 'lstat' are inlined
 versions of other functions, and no inlining is done without optimization.
 Recompile with -O.

 3) You might also have to compile with -D_GNU_SOURCE or -D__USE_GNU. Check
 out /usr/include/sys/stat.h; I've had trouble of this sort, but can't
 quite remember what it was. If you're using glibc2, then you should make
 a habit of compiling with -D_GNU_SOURCE.  

 HTH,
 --Rich

--
###########################################################################
#
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
#

 
 
 

glibc2 and 'stat'

Post by Marcus Sundber » Fri, 05 Sep 1997 04:00:00



>  2) You didn't compile with optimization. 'stat' and 'lstat' are inlined
>  versions of other functions, and no inlining is done without optimization.
>  Recompile with -O.

>  3) You might also have to compile with -D_GNU_SOURCE or -D__USE_GNU. Check
>  out /usr/include/sys/stat.h; I've had trouble of this sort, but can't
>  quite remember what it was. If you're using glibc2, then you should make
>  a habit of compiling with -D_GNU_SOURCE.

I have problems whith stat/lstat too (glibc 2.0.4, gcc 2.7.2.3).
Compiling with optimization fixes the problem when you are actually
calling stat() or lstat().
But even with -O2 -D_GNU_SOURCE -D__USE_GNU this will not work:

int (*xstat) ();
xstat = stat;

This prevwnts for example gnu findutils-4.1 from compiling.
Anyone now how to get around this?

//Marcus
--
-------------------------------+-------------------------------------
        Marcus Sundberg        | WWW: http://www.e.kth.se/~e94_msu/
 Royal Institute of Technology |             E-Mail:

 
 
 

glibc2 and 'stat'

Post by Richard Cr » Fri, 05 Sep 1997 04:00:00



 : >
 : >  2) You didn't compile with optimization. 'stat' and 'lstat' are inlined
 : >  versions of other functions, and no inlining is done without optimization.
 : >  Recompile with -O.
 : >
 : >  3) You might also have to compile with -D_GNU_SOURCE or -D__USE_GNU. Check
 : >  out /usr/include/sys/stat.h; I've had trouble of this sort, but can't
 : >  quite remember what it was. If you're using glibc2, then you should make
 : >  a habit of compiling with -D_GNU_SOURCE.
 :
 : I have problems whith stat/lstat too (glibc 2.0.4, gcc 2.7.2.3).
 : Compiling with optimization fixes the problem when you are actually
 : calling stat() or lstat().
 : But even with -O2 -D_GNU_SOURCE -D__USE_GNU this will not work:
 :
 : int (*xstat) ();
 : xstat = stat;
 :

 Exactly what goes wrong here? I don't know what 2.0.4 does, but in 2.0.5
 'stat' is an inlined wrapper for a function called 'xstat'. Now since
 you have a function pointer of the same name here, maybe gcc is confuses...

 ---Rich

--
###########################################################################
#
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
#

 
 
 

glibc2 and 'stat'

Post by Ulrich Dreppe » Fri, 05 Sep 1997 04:00:00



> Well I'm sorry, but all the docs about glibc & stat just state the
> same thing as you've done above. I don't know how many times I've
> checked that and it's still not working.

Check what the linker does with adding -Wl,-t to the gcc command line.

-- Uli

Ulrich Drepper  \    ,-------------------'   \  76149 Karlsruhe/Germany

 
 
 

glibc2 and 'stat'

Post by Marcus Sundber » Fri, 05 Sep 1997 04:00:00




> > I have problems whith stat/lstat too (glibc 2.0.4, gcc 2.7.2.3).
> > Compiling with optimization fixes the problem when you are actually
> > calling stat() or lstat().
> > But even with -O2 -D_GNU_SOURCE -D__USE_GNU this will not work:

> > int (*xstat) ();
> > xstat = stat;

> > This prevwnts for example gnu findutils-4.1 from compiling.
> > Anyone now how to get around this?

> Simply install glibc corectly and remove all hints for libc5.  By this
> I mainly mean there must not be any libc.so link or file around (in
> many cases in /lib).  This is wrong, there must only be one libc.so in
> /usr/libc and this is a linker script which does all the magic.

I've allready made sure that /usr/lib/libc.so is the file that comes
with glibc, and there are no other libc.so in the entire filesystem.

Quote:> This is really the last time I answer such stupid questions.  I really
> cannot stand it anymore that nobody is reading the documentation.
> Everybody is whining that not everything is documented but if
> something is documented it will simply be ignored.

Well I'm sorry, but all the docs about glibc & stat just state the same
thing as you've done above. I don't know how many times I've checked
that
and it's still not working.

//Marcus
--
-------------------------------+------------------------------------
        Marcus Sundberg        | WWW: http://www.e.kth.se/~e94_msu/
 Royal Institute of Technology |             E-Mail:

 
 
 

glibc2 and 'stat'

Post by Horst von Bra » Sun, 07 Sep 1997 04:00:00


On Thu, 04 Sep 1997 10:10:33 +0200,


>>  2) You didn't compile with optimization. 'stat' and 'lstat' are inlined
>>  versions of other functions, and no inlining is done without optimization.
>>  Recompile with -O.

[...]

Quote:>But even with -O2 -D_GNU_SOURCE -D__USE_GNU this will not work:
>int (*xstat) ();
>xstat = stat;

Look at the output of gcc -E, and check if stat is inline. Even if it is,
the compiler must provide an out of line version for this use (at least that
is what C++ implies).

At least here, gcc-2.7.2.2.f.2 (2.7.2.2 patched for f77) compiles that fine
without any problems, generating an ad hoc version of stat (libc-5.4.38, but
stat is inline too). Besides, for glibc you should be using gcc-2.7.2.3.
--

Casilla 9G, Vi?a del Mar, Chile                               +56 32 672616

 
 
 

glibc2 and 'stat'

Post by Mathias Froehlic » Wed, 17 Sep 1997 04:00:00



> Then the troubles arose.

> Because I wanted to make a complete transition, I began to reconfigure and
> recompile gcc.  It didn't work: the first program in gcc's build process
> which was compiled got an immediate segmentation fault upon start.

> Hmmm.  I wrote and compiled a small hello-world program and started it ->
> segmentation fault

> I reconfigured and recompiled the binutils (without installing) and tried
> things like ld/ld.new -V -> segmentation fault

> After haven some more grief with it I recovered to libc-5.

> QUESTION: what went/did I wrong?  what would be a correct transition
> procedure?

Have you changed the name of the dynamic linker to ld.so.2 in the gcc
specs file?

If you have not, the startup binary will start the wrong dynamic
linker which is mostly incompatible with the old one!
(... core dumped :-)

Mathias Froehlich

--

Institut f"ur Mathematik, Universit"at T"ubingen, D-72076 T"ubingen

 
 
 

1. Glibc2 + Undefined reference to 'stat'

I recently upgraded my libc5 Slackware system to glibc-2.0.6, and
I have found that there are a great number of programs that I can't
compile, due to errors such as:

/tmp/cca222691.o: In function `main':
/tmp/cca222691.o(.text+0x67e): undefined reference to `stat'
/tmp/cca222691.o(.text+0x7e6): undefined reference to `stat'
/tmp/cca222691.o: In function `copystat':
/tmp/cca222691.o(.text+0x150c): undefined reference to `stat'

(or other stat references--eaccess_stat, for example).

Have I done something wrong, and what can I do to repair my system?

TIA.

  //===============Chad Wolfsheimer=======Brown University===============\\
 //===================UNIX System/Network Administration==================\\

  \\==============http://bootp-249.diman.brown.edu/~cwolfshe=============//

2. secured news server

3. converting 'struct stat' to 'struct __old_kernel_stat'?

4. ThinkPad600 FreeBSD kernel config?

5. Runtime Error: can't resolve symbol 'stat'

6. iolan+ terminal server for console access via lan

7. glibc2.1.x + gnu.org 'political issues'??

8. Linux and the MIRO 12PD

9. symbol 'stat'

10. How to suppress 'Cannot stat "xxx"' message in tcsh

11. bug affecting 2.4.x's /proc/stat's disk_io

12. Stats for 'referer_log' on NCSA httpd

13. When updating LILO, 'stat /dev/printer no device'