Menu

Linking libtiff in MS Visual Studio C++

Help
2006-09-20
2012-07-26
  • Jack Schmidt

    Jack Schmidt - 2006-09-20

    I can't puzzle out these link errors, and I would appreciate any hints. I'm well-versed in libtiff on hpux, but a newbie on Win.

    The first problem is a warning from the linker:

    warning LNK4248: unresolved typeref token (01000016) for 'tiff'; image may not run

    The second problem is that when I run the .exe I get a message window that says:

    This application has failed to start because libtiff3.dll was not found.  Re-installing the app may fix this problem.
    

    Context:

    I got the bits from http://prdownloads.sourceforge.net/gnuwin32/tiff-3.8.2-1.exe?download which is accessible via http://gnuwin32.sourceforge.net/packages/tiff.htm

    Here's my C:\Program Files\GnuWin32\lib dir:

    libtiff.def
    libtiff.dll.a
    libtiff.lib
    libtiff-bcc.lib

    That directory is indeed in my LIB environment variable, and it is first. I also specifically added it to the linker's args.

    Here are the linker args according to the build log:

    /OUT:"C:\Documents and Settings\jschmidt1\My Documents\Visual Studio 2005\Projects\hartanal\Debug\hartanal.exe" /INCREMENTAL /LIBPATH:"c:\Program Files\GnuWin32\lib" /MANIFEST /MANIFESTFILE:"Debug\hartanal.exe.intermediate.manifest" /DEBUG /ASSEMBLYDEBUG /PDB:"c:\Documents and Settings\jschmidt1\My Documents\Visual Studio 2005\Projects\hartanal\debug\hartanal.pdb" /MACHINE:X86 /FIXED:No "..............\Program Files\GnuWin32\lib\libtiff.lib"
    ".\Debug\AssemblyInfo.obj"
    ".\Debug\Gridsurf.obj"
    ".\Debug\hartanal.obj"
    ".\Debug\stdafx.obj"
    ".\Debug\app.res"

    My Visual Studio 2005 is Version 8.0.50727.42,
    running on XP Pro version 5.1.2600 Service Pack 2 Build 2600

    Thanks for any and all help.

     
    • Nobody/Anonymous

      I'm finding that if you use the prebuilt libtiff from Gnu, you need to include these dll's in the folder with your project's exe:
      libtiff3.dll
      zlib1.dll
      jpeg62.dll

      However, you don't need to include these (at least to get your exe running in the first place):
      glut32.dll
      libimage.dll
      libpng13.dll

      All these dlls are distributed in GnuWin32\bin

      It is perhaps unfortunate, for those of us who don't want to be bothered rebuilding the library, that control of which of these dlls is required is determined by compile-type settings in tiffconf.h, rather than by, say, reading a ini file on startup.

      Glenn Pearson
      software developer, MSD Inc., at US National Library of Medicine

       
    • Nobody/Anonymous

      Which verson of MSVC are you running?

      I'm running MSVC2003. To put it mildly, I think the Win32 port of LIBTIFF (tiff-3.8.2-1.exe) is highly suspect. I did get it to link (instructions below) but when I run it to open any TIFF file (I've tried many variations from different sources) it fails with an assertion error:

      Assertion failed!
      File: ../../tiff-3.7.3-src/libtiff/tif_dirinfo.c
      Line: 457
      Expression: tif->tif_fieldinfo != NULL

      I was trying to run the tiff2raw.c utility (link below). Why does something supposedly of version 3.8.2-1 reference a source file in directory 3.7.3. And what sort of error is that? An assertion. All TIFF2RAW does is try and open the file. I wasted a day trying to muck around, but I think LIBTIFF is suspect and I gather it isn't supported either. Bloody horrible graphics format. I'm looking for a utility that will convert large TIFF files to something (anything) else. All the utilites in LIBTIFF convert to TIFF, rather than away from it. Does anyone know an alternate utility.

      As for linking in MSVC2003: Your error looks quite strange. Open the MSVC project Properties tab, choose Configuration Properties | Linker | Input and add libtiff.lib to additional dependencies. Then go to Main Menu Tools | Options | VC++ directories and add C:\Program Files\GnuWin32\include to Include and C:\Program Files\GnuWin32\lib to Lib. Leave your project in _cdecl mode (if you're using a *.c); may have to try something else if you're mixing .cpp and .c.

      That gets it to link, but as described above it doesn't run. Has anyone else there actually seen 3.8.2-1 work under Windows?

      Short of that, I'd say LIBTIFF is a pile of crap and you should migrate your graphics to another standard. TIFF always struck me as a stupid, overly convoluted design slung together by some crappy programmers who failed to grasp keep-it-simple-stupid. LIBJPEG and LIBPNG work out of the box. LIBTIFF doesn't. Avoid ut.

      http://sipi.usc.edu/database/tiff2raw.c
      http://gnuwin32.sourceforge.net/packages/tiff.htm

       
      • Nobody/Anonymous

        The example tiff2raw works with Mingw. So I doubt that there is something wrong with the tiff library or the gnuwin32 port.

         
MongoDB Logo MongoDB