AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2007.03.09 21:20 "[Tiff] Regarding NULL TIFFOpen return on Windows", by W Bradford Paley
2007.03.10 02:45 "Re: [Tiff] Regarding NULL TIFFOpen return on Windows", by Joris
2007.03.10 07:52 "Re: [Tiff] Regarding NULL TIFFOpen return on Windows", by W Bradford Paley
2007.03.11 05:51 "Re: [Tiff] Regarding NULL TIFFOpen return on Windows", by Edward Lam
2007.03.12 17:27 "[Tiff] Problem fixed: TIFFOpen() returns NULL on MS VC++", by W Bradford Paley

2007.03.10 07:52 "Re: [Tiff] Regarding NULL TIFFOpen return on Windows", by W Bradford Paley

Try other filenames, try opening for reading instead of writing. If that still doesn't work, try properly hooking into the error mechanism, and see what error is reported.

Thanks, Joris! The list seems active indeed.

I had already tried other file names and opening for reading rather than writing. I always get a 0 response from TIFFOpen().

Wondering whether I was misusing the library was what prompted me to find and build that other version. Once I linked with that one, TIFFOpen() with the exact same parameters worked fine.

Thanks for the suggestion of hooking into the error mechanism. I tried hooking into the error mechanism with the same result: it works with the other version of the library (the error handler doesn't get called unless I supply an impossible name, like "???", an then it gives me a proper error).

---

So I created a tiny test program in a new Visual Studio solution:

#include "stdafx.h"
#include "stdio.h"
using namespace std;
#include "tiffio.h"

int _tmain(int argc, _TCHAR* argv[])
{
         cout << "Hello, LibTIFF\n";

         TIFF *tif = TIFFOpen("test.tif", "r");
         if (tif) {
                 TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, 400);
                 //... other set field commands removed
         } else {
                 cout << "could not open TIFF file for writing\n";
                 return 0;
         }
         return 0;
}

---

Then I installed an error handler:

void tiff_error_handler(const char *s1, const char *s2, va_list ap)
{
         cout << "local error handler\n s1: '" << s1 <<
"'\n s2: '" << s2 << "'\n";
         vfprintf(stderr, s2, ap);
         cout << endl;
}

with:
         TIFFSetErrorHandler((TIFFErrorHandler)tiff_error_handler);

and when I debug/execute the program, it breaks in the file "ostream" when it tries to execute that TIFFSetErrorHandler().

It breaks at the very last line of:

template<class _Traits> inline
         basic_ostream<char, _Traits>& __cdecl operator<<(
                 basic_ostream<char, _Traits>& _Ostr,
                 const char *_Val)

---

Perhaps this is not a LibTIFF issue, but one about the VC++ configuration needed to use LibTIFF. I could not find any step-by-step guides for using LibTIFF with Visual C++, so I did what seemed to work for FreeType. I wonder if any VC++ user might verify that these are the right steps:

         to Linker->Input->Additional Dependencies

It compiles fine, but I still get that 0 return from TIFFOpen().

And once again, when I link exactly the same code with my home-built (with someone else's VC++ project) tiff-v3.6.1, it runs like a charm.

---

I have put a zip file of that VC++ solution in the Web dir http://wbpaley.com/projects/illustrations, it's called TIFFOpenTestTinyProgram.zip if anyone wants to try it.

I would be happy to hire someone for an hour or two to help me if this goes beyond the usual scope of requests for help on this list. I may be doing something very wrong since I'm just coming back up to speed on C++, and have never used it before on Windows. (I first used it on serial number 000049 Silicon Graphics Iris 1400!)

Kind Regards,
Brad

W. Bradford Paley

Digital Image Design Incorporated 170 Claremont Suite 6 New York NY 10027
http://didi.com/brad http://informationEsthetics.org http://textarc.org
http://google.com/search?&q=%22Brad+Paley%22+OR%22+Bradford+Paley%22+-flash
(917) 686-3274