2007.06.29 11:04 "[Tiff] Suggested Source Changes for Building libtiff Under Windows", by Kevin Myers

2007.06.29 11:04 "[Tiff] Suggested Source Changes for Building libtiff Under Windows", by Kevin Myers

Dear libtiff maintainers,

I've just spent most of the past two days struggling with getting libtiff to build successfully under Windows. During the process, I came across what I believe to be a number of deficiencies in the present source code that could be addressed in order to simplify builds under Windows. Following below are a number of specific suggestions that I believe would be helpful in this regard. Note that I have successfully built libtiff under Windows using the MSVC compiler with all of the changes in place that are suggested below.

I hope that someone will be able to implement these changes. There are both standard libtiff and GnuWin32 specific issues. I believe that addressing these issues would make builds under Windows a lot easier, especially for folks like me who don't do this kind of thing on an everyday basis.

Hope these suggestions are helpful.

Kevin M.

1. Expand handling for HAVE_GETOPT to additional modules.

For each of the following modules in the tools directory:

tiffdump.c, rgb2ycbcr.c, tiff2pdf.c, tiff2ps.c, tiffmedian.c, tiffinfo.c, tiff2bw.c, tiffdither.c,

tiff2rgba.c, fax2ps.c, tiffcp.c, ras2tiff.c, bmp2tiff.c, fax2tiff.c, gif2tiff.c, pal2rgb.c

Add the following block of code near the top of each file:

#ifndef HAVE_GETOPT
extern int getopt(int, char**, char*);
#endif

Adding this code will avoid unnecessary compiler warnings under Windows, and make these modules consistent with others in the tools directory for which this block of code is already in place.

2. Expand handling for HAVE_IO to additional modules.

For the following module in the tools directory:

tiff2pdf.c

Add the following block of code near the top of the file:

#ifdef HAVE_IO_H
# include <io.h>
#endif

Adding this code will avoid unnecessary compiler warnings under Windows, and make this module consistent with others in the tools directory for which this block of code is already in place.

3. Expand handling for HAVE_STRCASECMP to additional modules.

For the following module in the tools directory:

tiffinfo.c

Add the following block of code near the top of the file:

#ifndef HAVE_STRCASECMP
extern int strcasecmp(const char *s1, const char *s2);
#endif

Adding this code will avoid unnecessary compiler warnings under Windows, and make these modules consistent with others in the tools directory for which equivalent blocks of code are already in place.

4. Expand handling for additional configuration settings under Windows.

Replace the following module in the libtiff directory (currently this file only exists in the GnuWin32 port):

tif_config.h.vc

Note: Much of the following was generated by running configure under MinGW. However, configure can't be used directly with most Windows developers default command shells, and some of the settings used for the MinGW configuration aren't appropriate when using the MSVC compiler (nmake). Therefore attempting to customize the content of this file *after* it has already been downloaded by the user may be a poor option. Also, there are a number of specific settings in this file that I found to be needed in addition to the much more limited set that is included in the current GnuWin32 version.

Use the following code:

/* Support CCITT Group 3 & 4 algorithms */
#define CCITT_SUPPORT 1

/* Pick up YCbCr subsampling info from the JPEG data stream to support files

lacking the tag (default enabled). */
#define CHECK_JPEG_YCBCR_SUBSAMPLING 1

/* Support C++ stream API (requires C++ compiler) */
#define CXX_SUPPORT 1

/* Treat extra sample as alpha (default enabled). The RGBA interface will

treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many

packages produce RGBA files but don't mark the alpha properly. */
#define DEFAULT_EXTRASAMPLE_AS_ALPHA 1

/* Use the Apple OpenGL framework. */
/* #undef HAVE_APPLE_OPENGL_FRAMEWORK */

/* Define to 1 if you have the <assert.h> header file. o