TIFF and LibTiff Mail List Archive

2000.03.27 02:36 "stderr redirection", by Byron Young

I successfully compiled the libtiff distribution using nmake, cl, link for a Win32 system running W98. In the makefile (attached to this email), I selected


Attempting to redirect stderr to a file, I reopened the stderr file using

Begin WinMain
FILE * fp;
char buf[128];
char tm[16];
char dt[16];

fp = freopen("stderr.txt","w+",stderr);
sprintf(buf,"Starting Program %s %s\n",tm,dt);

end of WinMain

The stderr.txt file is opened, and the date and time are written to stderr. According to the html manual,

TIFFError invokes the library-wide error handling function to (normally) write an error message to the stderr.

However, when errors occur while a TIFF libtiff function is called, the error output is NOT written to stderr.txt.

When I rebuild the libtiff distribution with WINMODE = -DTIF_PLATFORM_WINDOWED

Each error that the TIFF libtiff function generates correctly displays a message box stating the error.


How do I tell the TIFF libtiff functions (compiled with WINMODE = -DTIF_PLATFORM_CONSOLE) to use the freopen stderr file?


Byron Young

#       Simple MS VC++ Makefile
#       To build:
#       C:\libtiff\libtiff> nmake /f all


# Select _CONSOLE to build a library which reports errors to stderr, or # _WINDOWED to build such that errors are reported via MessageBox().


CC = cl
INCL = -I.
LIBS = user32.lib
CFLAGS = /nologo /W3 $(INCL) $(WINMODE) /c /G4 /LD /Zi

OBJ     = \
        tif_aux.obj \
        tif_close.obj \
        tif_codec.obj \
        tif_compress.obj \
        tif_dir.obj \
        tif_dirinfo.obj \
        tif_dirread.obj \
        tif_dirwrite.obj \
        tif_dumpmode.obj \
        tif_error.obj \
        tif_fax3.obj \
        fax3sm.obj \
        tif_getimage.obj \
        tif_jpeg.obj \
        tif_flush.obj \
        tif_luv.obj \
        tif_lzw.obj \
        tif_next.obj \
        tif_open.obj \
        tif_packbits.obj \
        tif_pixarlog.obj \
        tif_predict.obj \
        tif_print.obj \
        tif_read.obj \
        tif_swab.obj \
        tif_strip.obj \
        tif_thunder.obj \
        tif_tile.obj \
        tif_win32.obj \
        tif_version.obj \
        tif_warning.obj \
        tif_write.obj \

ALPHA = ..\dist\tiff.alpha

default: libtiff.lib

all:    libtiff.lib libtiff.dll

libtiff.lib: $(OBJ)
        lib /out:libtiff.lib $(OBJ)

libtiff.dll: $(OBJ)
        link /machine:i386 /dll /def:libtiff.def /out:libtiff.dll \
                $(OBJ) $(LIBS)

version.h: $(VERSION) $(ALPHA) mkversion.c
        $(CC) mkversion.c
        del version.h
        .\mkversion.exe -v $(VERSION) -a $(ALPHA) version.h

        del *.obj *.lib libtiff.dll

tif_version.obj: version.h