After much searching through the code and a lot of debug statements, I have finally solved this problem. It turned out that the size of the value returned by off_t via the fstat function was only 32-bits, not the expected 64-bits as it would be if 64-bit support was enabled.
I checked through my makefile and it seems to show that it is being enabled correctly
-
CFLAGS = -D_FILE_OFFSET_BITS=64 -Wall -Iadmxrc2 -Iadmxrc2/common -Iinclude
-
-
LDFLAGS = -L. $(LIBPATH)
-
-
SRCS = Debug.cpp \
-
FileReader.cpp \
-
Monitor.cpp \
-
Control.cpp \
-
Main.cpp
-
-
all: main
-
-
main: libcommon.a libnet.a $(SRCS:.cpp=.o)
-
-
$(CXX) $(LDFLAGS) $(CFLAGS) $(SRCS:.cpp=.o) -lccgnu2 -ldl -ladmxrc2 -o fpc_main -L"./lib" -lcommon -lnet
-
libnet.a:
-
make -C ./lib/net -f net.mak
-
-
libcommon.a: args.o time.o
-
ar r ./lib/libcommon.a args.o time.o
-
-
args.o: admxrc2/common/args.c admxrc2/common/common.h
-
$(CC) -c $(CFLAGS) -o $@ admxrc2/common/args.c
-
-
time.o: admxrc2/common/time.c admxrc2/common/common.h
-
$(CC) -c $(CFLAGS) -o $@ admxrc2/common/time.c
-
-
clean:
-
rm -f $(TARGET) *.o *.a
-
make -C ./lib/net -f net.mak clean
-
-
But upon a clean compilation of the files, I noticed that 64-bit support was enabled for the C functions but not the C++ functions
[code]
gcc -c -D_FILE_OFFSET_BITS=64 -Wall -Iadmxrc2 -Iadmxrc2/common -Iinclude -o args.o admxrc2/common/args.c
gcc -c -D_FILE_OFFSET_BITS=64 -Wall -Iadmxrc2 -Iadmxrc2/common -Iinclude -o time.o admxrc2/common/time.c
ar r ./lib/libcommon.a args.o time.o
make -C ./lib/net -f net.mak
make[1]: Entering directory `/home/lib/net'
cc -c -o net_endpt.o net_endpt.c
cc -c -o net_error.o net_error.c
cc -c -o net_io.o net_io.c
cc -c -o net_tcp.o net_tcp.c
ar rv ../libnet.a net_endpt.o net_error.o net_io.o net_tcp.o
ar: creating ../libnet.a
a - net_endpt.o
a - net_error.o
a - net_io.o
a - net_tcp.o
make[1]: Leaving directory `/home/lib/net'
g++ -c -o Debug.o Debug.cpp
g++ -c -o FileReader.o FileReader.cpp
g++ -c -o Monitor.o Monitor.cpp
g++ -c -o Control.o Control.cpp
g++ -c -o Main.o Main.cpp
[\CODE]
To rectify this, I specified that the offset to be used was 64-bits in the FileReader.h file, thus making certain that all applicable functions called would return 64-bit values, not 32-bits.
-
#ifndef FILEREADER_H_
-
#define FILEREADER_H_
-
-
// Larger file support for files greater then 20 gigabytes
-
#ifndef _LARGEFILE_SOURCE
-
#define _LARGEFILE_SOURCE
-
#endif
-
#ifndef _LARGEFILE64_SOURCE
-
#define _LARGEFILE64_SOURCE
-
#endif
-
-
#define _FILE_OFFSET_BITS 64 //definition of offset size
-
-
#include <stdlib.h>
-
#include <unistd.h>
-
#include <features.h>
-
#include <ctype.h>
-
#include <cc++/thread.h>
-
This fixed the problem immediately. But I feel that this solution is inelegant, as I would prefer that the Makefile handles the large file support for bith the C files and the C++ files. How does one ensure that the file_offset is 64 for the C++ files as well as the C files in compilation? What must I include in the Makefile so that all the C++ files use large file support?
Thanks, Lars