[vlc-devel] [PATCH] Fix for trac #3452: VLC fails to compile on OS X with zlib 1.2.4

Gellule Xg gellule.xg at free.fr
Mon Mar 29 22:23:06 CEST 2010

This is a second version of the patch for for trac #3452: VLC fails to 
compile on OS X with zlib 1.2.4. The actual patch files are unchanged, 
but the supporting explanantion is improved.

Best regards,

1. Issue on OS X with zlib 1.2.4
Compilation of VLC on OS X with the latest version of zlib (version 
1.2.4) fails. The error is related to off64_t not being defined on OS X. 
This off64_t appears in zlib.h header when _LARGEFILE64_SOURCE is set. 
The actual compilation error message is given in the trac ticket.

_LARGEFILE64_SOURCE is used to expose the 64bit equivalents of off_t 
lseek, lstat... respectively off64_t, lseek64, lstat64... As described 
in the libc documentation found at 
this is a transitional API put in place when libc file access was 
transitionning from 32bits to 64bits. There is another flag realted to 
64bits file access which is _FILE_OFFSET_BITS=64. This flag makes the 
old 32bit API 64bits directly, ie, off_t, lseek, lstat... are all 
64bits. Both flags have the same end purpose but _FILE_OFFET_BITS=64 
should now be the prefered way, moving file access to 64bits. As a side 
note, OS X had 64bits file access right from the beginning (and BSD as 
well actually). This is why there is no off64_t on OS X.

4. Intent of the patch
The intent of the patch is to get rid of _LARGEFILE64_SOURCE and keep 
_FILE_OFFSET_BITS=64. This will modernize VLC's file access and also 
take care fo the issue on OS X.

3. VLC's code analysis
I first performed a code analysis of VLC to see if the transitional API 
was still in use. I grepped for any of the following {off64_t, fpos64_t, 
fopen64, freopen64, ftello64, fseeko64, fgetpos64, fsetpos64, open64, 
create64, pread64, pwrite64, lseek64, mmap64, aiocb64, aio_read64, 
aio_write64, lio_listio64, aio_error64, aio_return64, aio_fsync64, 
aio_suspend64, aio_cancel64, __ftw64_func_t, __nftw64_func_t, ftw64, 
nftw64, stat64, ino_t64, blkcnt64_t, fstat64, lstat64, truncate64, 
ftruncate64, tmpfile64, getrlimit64, setrlimit64, rlimit64} which should 
cover the entire traitional 64 api. I found the following, removing 
results from changelogs, and text files:

# egrep -r '(off64_t|fpos64_t|fopen64|freopen64|ftello64|fseeko64|
setrlimit64|rlimit64)' .

./extras/contrib/src/Makefile:	(cd $<; $(HOSTCC) ./configure $(HOSTCONF) 
--enable-static --prefix=$(PREFIX) CFLAGS="$(CFLAGS) -Dlseek64=lseek 
-Doff64_t=off_t" && make && make install)

-Dlseek64=lseek and -Doff64_t=off_t are not needed anymore. lseek64 and 
off64_t are nowhere else in extras/contrib/src. This is the purpose of 
the first attached patch file.

./extras/contrib/src/Patches/libdvdread-win32.patch: #define lseek64 

This is a win32 patch, I left it alone.

Then I looked for all the _LARGEFILE64_SOURCE

#egrep -r LARGEFILE64_SOURCE .

./src/vlc-plugin.pc:	-D_LARGEFILE64_SOURCE \
./src/vlc-plugin.pc.in:	-D_LARGEFILE64_SOURCE \
./vlc-config:cppflags="${cppflags} -D_FILE_OFFSET_BITS=64 -D__USE_UNIX98 
./vlc-config.in:cppflags="${cppflags} -D_FILE_OFFSET_BITS=64 
./vlc-config.in.in:cppflags="${cppflags} -D_FILE_OFFSET_BITS=64 

In ./src/vlc-plugin.pc.in there is already a _FILE_OFFSET_BITS=64 with 
the _LARGEFILE64_SOURCE found by grep. Getting rid of it is the purpose 
of the second attached patch.

In ./vlc-config.in.in, we have the same situation, and this is the 
purpose of the last attached patch.

4. Verifications
All three patches have been applied and tested on OS X and linux (Latest 
Ubunutu). I haven't found any compilation/execution issue.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch-extras_contrib_src_Makefile.diff
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20100329/b2d0a907/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch-src_vlc-plugin.pc.in.diff
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20100329/b2d0a907/attachment-0001.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch-vlc-config.in.in.diff
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20100329/b2d0a907/attachment-0002.ksh>

More information about the vlc-devel mailing list