2015.09.15 10:41 "[Tiff] "bad file descriptor" if operating with lseek on filedescriptor given by TIFFFileno (Windows only)", by Andreas Romeyke

2015.09.15 13:14 "Re: [Tiff] "bad file descriptor" if operating with lseek on filedescriptor given by TIFFFileno (Windows only)", by Bob Friesenhahn

I am using the filedescriptor returned by TIFFFileno() to make additional checks on a given TIFF. Under Linux the code works as expected.

But if I crosscompile the Libtiff and my program with MinGw using:

Libtiff:
  ./configure --host=i686-w64-mingw32

(also CFLAGS=-DO_BINARY does not help)

the lseek() or the read() comes with errno "Bad file descriptor".

Could you point me how to fix that?

What release of libtiff are you using (latest is 4.0.6)?

If a recent version, have you tried passing the --disable-win32-io option to configure? This would cause tif_unix to be used for I/O, which is directly using a traditional fileno rather than retrieving one from the tif_win32 I/O code. Due to an interfacing issue in libtiff, it may be that tif_unix operates more correctly than tif_win32.

MinGW has a weakness in that it often targets a CDK which is too old to support large files using POSIX-style I/O.

Bob
--
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/