[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 20030618:undefined reference to `__ctype_b'



>To: address@hidden
>From: "Bryan G. White" <address@hidden>
>Subject: undefined reference to `__ctype_b'
>Organization: UCAR/Unidata
>Keywords: 200306182219.h5IMJ2Ld004225

Hi Bryan,

> Found this in the email archives:
> 
> >> 
> >> /nfs/user22/netcdf-3.5.0/src/libsrc/libnetcdf.a(string.o)(.text+0x37): In 
> >> function
> >> `NC_check_name':
> >> : undefined reference to `__ctype_b'
> >> collect2: ld returned 1 exit status
> >> 
> >> Any idea how to fix this? 
> >
> >The reference to `__ctype_b' should be satisfied by the C runtime
> >library.  Either your linker isn't referencing the C runtime library, or
> >the necessary definition is missing from the C runtime library that the
> >linker is using.  This latter case could be becaue the compiler that was
> >used to compile the netCDF file "string.c" assumed a differenct C runtime
> >library than the one actually used by your linker.
> 
> The problem is related to glibc.  Anything on redhat9 with a glibc >=
> glibc-2.3.2-11.9 is causing the problems.  Actually, any stock glibc
> from atleast 2.3.0 and on is causing problems.
> 
> glibc is no longer exporting ctype_b.
> The compat_symbol lines were removed from ctype/ctype-info.c in the
> newer glibc libraries.  RedHat8 kept the lines in ctype-info.c
> to support old static libraries.
> 
> The offending line of code in netcdf is in libsrc/string.c.
> The line is:  
>    if(!isalnum(ch))
> 
> isalnum is found in /usr/include/ctype.h.  ctype.h does have
> reference to ctype_b.
> Sorry, I'm not much of a C programmer and I can't follow what's
> going on.
> 
> My temporary solution is to compile netcdf on a RedHat 8 system
> and transfer it over to RedHat 9.

Thanks for letting us know about this.  We haven't upgraded any of our
RedHat platforms to RedHat 9 yet, so hadn't seen this, but I think our
RedHat 8 may have glibc-2.3.2.  Since isalnum() is required by ANSI C
(ANSI C3.159-1989), I think any ANSI-compliant C development
environment must support it.  Maybe the problem is that the argument
to the isalnum() macro is supposed to be representable as an unsigned
char.  We'll check if we can duplicate the problem on RedHat 8 with
glibc-2.3.2 and see if the code works when an (unsigned char) cast is
inserted, as in:

    if(!isalnum((unsigned char)ch))

--Russ