Hi I am using the dev c++ compiler can somebody please guide me as tohow I should integrate libtiff and its associated header files with the c++ compiler .I am on a deadline so any help would be greatly appreciated.

Can somebody also be kind enough to run this code as to see if its working as I am not able to integrate libtiff to my compiler.

the code is supposed to read in two images or more and composite them ..
Thanks

#include <stdio.h>
#include <tiffio.h> // Includes the TIFF APIs Declarations

int main(int argc,char * argv[])
{
   TIFF *tif_in,*tif_out; // Tiff file pointers creation
   int i,s;
   unsigned int imagelength,row,samples;
   tdata_t buf;

   if ( argc < 4 )
   {
      printf("USAGE program file1 file2...[fileN] outputfile\n");
      return 0;
   }

// Opening output file in append mode will help to append to the previous runs.
   tif_out=TIFFOpen(argv[argc-1],"a");
   if ( tif_out==NULL )
   {
      printf("unable to open file %s \n",argv[argc-1]);
      return 0;
   }

// Looping for all input files 

   for ( i= 1;i < argc-1;i++ )
   {
      tif_in=TIFFOpen(argv[i],"r");
      if ( tif_in != NULL )
      {
         TIFFGetField(tif_in,TIFFTAG_IMAGELENGTH,&imagelength);
         TIFFGetField(tif_in,TIFFTAG_SAMPLESPERPIXEL,&samples);
         buf = _TIFFmalloc(TIFFScanlineSize(tif_in));
         for ( s=0;s<samples;s++ )
         {
            for ( row =0;row<imagelength;row++ )
            {
               TIFFReadScanline(tif_in,buf,row,s);
               TIFFWriteScanline(tif_out,buf,row+i,s+i);
            }
         }
         _TIFFfree(buf);
         TIFFClose(tif_in);
      }
      else
      {
         printf("unable to open file %s \n",argv[i]);
         TIFFClose(tif_in);
         TIFFClose(tif_out);
         return 0;
      }

   }
   TIFFClose(tif_out);
   return 1;
}

<< moderator edit: added [code][/code] tags and indenting >>

Dani AI

Generated

A concise, practical checklist for getting libtiff working with Dev-C++ (MinGW), plus a few troubleshooting tips that address points raised by and the follow-ups from and .

Typical integration steps

  1. Obtain libtiff source (or a MinGW-compatible binary). libtiff commonly requires zlib and, for JPEG-compressed TIFFs, libjpeg (and optionally libpng).
  2. Build with the same toolchain as Dev‑C++ (MinGW). Two common routes were used in this thread: let Dev‑C++ create a static library project and add the libtiff .c files (as @AncientDragon did), or build from source in an MSYS/MinGW shell (configure && make) to produce a .a import/static library. Mixing MSVC-built libs with MinGW often fails.
  3. Install headers and tell the compiler where to find them (copy tiffio.h into the MinGW include path or add the folder to the project include paths).
  4. Tell the linker where the .a lives, then link libtiff and its dependencies. Example linker args (order matters): -ltiff -ljpeg -lz or add the specific .a files to the project. Libraries that a library depends on must appear after it on the linker command line.

Common failure modes and quick checks

  • “Missing tiffio.h”: header not on include path.
  • “Undefined reference to TIFFOpen” or similar: libtiff not linked, wrong library path, wrong bitness (32‑bit vs 64‑bit), or a compiler/runtime mismatch. Confirm the library was built with MinGW and matches the target architecture.
  • Compressed TIFFs require the compression libs at link time; unresolved symbols for compression routines usually indicate a missing -lz or -ljpeg.
  • Using the Dev‑C++ project attachments posted by can save time; ensure project directory paths are updated to where the libraries and headers actually live.

These steps cover the usual causes of integration pain with Dev‑C++. If linker errors persist, the exact error text and the list of specified libraries usually pinpoint whether the problem is an include/path issue, a missing dependency, or a toolchain mismatch.

Recommended Answers

All 4 Replies

what is TIFF api? my copy of dev-c++ does not contain tiffio.h

what is TIFF api? my copy of dev-c++ does not contain tiffio.h

I'm guessing , but I'm not familiar with it.

Thanks for the link Dave.

Thiru.y: You will have to rebuild the tifflib before you can use it. I'm just starting this myself and have not yet successfully been able to link your program the the library that Dev-C++ produced. I created a static C library, so maybe that is the problem.

First you will have to create your own Dev-C++ library, add the tiff *.c files to it, then compile the library. Dev-C++ will generate *.a file -- libraries on *nix and Dev-C++ have .a extension. I'll let you know when I get a successful build and link.

If anyone else successful with this please post.

I finally got it to compile and link -- don't know if it really works or not. Attached it the Dev-C++ projects for the library and the test program that you posted.

I have all my libttif files in c:\downloads\ttif\... If you put yours someplace else you will have to change the project directory settings.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.