Re: 64 bit LFS compile error
On Thu, May 28, 2009 at 06:18:56PM -0500, Leslie Rhorer wrote:
> > > I downloaded an application (mfs-tools) which I am trying to compile on
> > my
> > > Debian "Lenny" system, but the make is failing with the following
> > errors:
> > >
> > > gcc -DHAVE_CONFIG_H -I. -I../include -I../include -g -O2 -MT
> > > readwrite.o -MD -MP -MF .deps/readwrite.Tpo -c -o readwrite.o
> > readwrite.c
> > > readwrite.c: In function 'tivo_partition_read':
> > > readwrite.c:146: error: 'off64_t' undeclared (first use in this
> > function)
> > > readwrite.c:146: error: (Each undeclared identifier is reported only
> > once
> > > readwrite.c:146: error: for each function it appears in.)
> > > readwrite.c:146: error: expected ')' before 'sector'
> > > readwrite.c:146: error: expected ')' before 'sector'
> > > readwrite.c: In function 'tivo_partition_write':
> > > readwrite.c:261: error: 'off64_t' undeclared (first use in this
> > function)
> > > readwrite.c:261: error: expected ')' before 'sector'
> > > readwrite.c:261: error: expected ')' before 'sector'
> > > make[1]: *** [readwrite.o] Error 1
> > > make[1]: Leaving directory `/downloads/software/mfstools-src/lib'
> > > make: *** [all-recursive] Error 1
> > >
> > > I've searched for the error, and I found some background information,
> > but no
> > > clear suggestions on how to resolve the issue. I submitted the issue to
> > > some Usenet groups, and one of the respondents suggested I report the
> > issue
> > > here. Clearly, the off64_t type is not defined in any of the headers.
> > I
> > > have glibc-source installed, and it looks to me like the type may be
> > > defined there, but the make is not seeing it.
> >
> > On amd64 off_t and all the others are naturally 64bit. And for 32bit
> > code you should rather enable LFS so off_t is 64bit instead of using
> > off64_t (adding -D_FILE_OFFSET_BITS=64).
>
> I'm sorry, but I don't quite follow your meaning. Are you saying I should
> replace all references to off_64t with off_t in readwrite.c? And I should
> add -D_FILE_OFFSET_BITS=64 to what file?
off64_t does exist. You need to do define _LARGEFILE64_SOURCE
(or _GNU_SOURCE), so something like:
#define _LARGEFILE64_SOURCE 1
#include <sys/types.h>
Instead of using a define in the source, you can also use
tell it to the compiler using gcc -D_LARGEFILE64_SOURCE=1
Instead of using off64_t, you could also use off_t and add the
output of 'getconf LFS_CFLAGS' to the gcc command line. If you're
using a Makefile, that would need to be added to the CFLAGS.
getconf LFS_CFLAGS will output something like something like
"-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" on arches that need
it. It will not change anything on amd64 since it's already
64 bit. Do not just always add those, it will break on some
arches.
If _FILE_OFFSET_BITS is defined, off_t will be replaced
by an off64_t.
If _LARGEFILE64_SOURCE is defined the off64_t type will
be available.
So what most applications want to do is use off_t
and use getconf LFS_CFLAGS.
Kurt
Reply to: