我有一個C程序我試圖編譯爲Mac OS X 10.6.4:如何在Darwin下啓用大文件支持?
$ uname -v
Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386
我gcc
如下:
$ gcc --version
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)
我Makefile
如下:
CC=gcc
CFLAGS=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -O3 -Wformat -Wall -pedantic -std=gnu99
all: myApp
rm -rf *~
myApp: myApp.o
${CC} ${CFLAGS} myApp.o -lbz2 -o myApp
rm -rf *~
clean:
rm -rf *.o myApp
問題是我的應用程序打電話給fseeko64
和fopen64
,並使用off64_t
偏移類型。當我編譯我的應用程序時,我得到以下警告和錯誤:
$ make myApp
gcc -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -O3 -Wformat -Wall -pedantic -std=gnu99 -c -o myApp.o myApp.c
myApp.c: In function ‘extractData’:
myApp.c:119: warning: implicit declaration of function ‘fseeko64’
myApp.c:119: error: ‘off64_t’ undeclared (first use in this function)
myApp.c:119: error: (Each undeclared identifier is reported only once
myApp.c:119: error: for each function it appears in.)
myApp.c: In function ‘extractMetadata’:
myApp.c:305: warning: implicit declaration of function ‘fopen64’
myApp.c:305: warning: assignment makes pointer from integer without a cast
我的代碼在Linux下無錯地構建。在Darwin下構建時,我可以對源代碼進行哪些更改以添加大文件支持?
謝謝,這很完美。 – 2010-10-23 10:37:38
@AlexReynolds我不會稱之爲完美,請參閱我的答案。 – aergistal 2015-09-05 08:55:19