2005.06.21 14:53 "[Tiff] VS7.1 compile problems", by Thom DeCarlo

2005.06.22 20:51 "Re: [Tiff] VS7.1 compile problems", by Andrey Kiselev

Problem 1: There is something flaky about the handling of the inline declaration in tif_fax3.c functions find0span and find1span. I had to comment out the word "inline" on lines 779 and 838 to get the file to compile.

Hello Thom,

In first of all I should say that the only supported method to build libtiff is via supplied makefiles. There are three makefiles with the .vc suffix which are specifically prepared for nmake utility.

When the library is being built with nmake tif_config.h.vc file becomes tif_config.h and it contains all defines, needed by MSVC. If you want to prepare your own project you should rename tif_config.h.vc manually and include it in your project.

Problem 2: The include file "tif_config.h" sets a bunch of constants to either 1 or 0 (existence or non-existence of specific include files). However, when these constants are tested in the code the tests often only check to see if the constant has been defined. It ignores the value of the constant and therefore always passes. The problems are with the tests of:

HAVE_UNISTD_H, HAVE_MMAP, HAVE_STRINGS_H, HAVE_FCNTL_H, HAVE_IO_H

Do a grep "#ifdef HAVE_UNISTD_H" and you'll find about two dozen occurrences in the libtiff and tools directories. I've changed all these to "#if" and the compiles succeed. I'm not sure if that actually fixes the problem, though. (See the next problem.)

That should never happens. HAVE_UNISTD_H should not be defined at all if the test for unistd.h fails. I can suppose you wrote that file manually, but you actually do not need to do that, because there is ready for use tif_config.h.vc. Anyway, if you do not have unistd.h you should write:

#undef HAVE_UNISTD_H

and not

#define HAVE_UNISTD_H 0

Problem 3: Now I'm trying to find the proper replacement for the unix functions read, write, lseek, close, open, and getopt. I'm getting lots of warnings about these things being undefined.

There are two ways to use Windows I/O functions. The first one used in the tif_win32.c module and the second one is in the tif_unix.c. I am recommend the second one. All above functions are declared in io.h header and should be always available when you are linking with the msvcrt library. You do not need any modification in sources to use any of these approaches, they are switched in the nmake.opt file (see USE_WIN_CRT_LIB option).

Best regards,
Andrey

Andrey V. Kiselev
Home phone: +7 812 5970603 ICQ# 26871517