AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2005.10.17 03:43 "[Tiff] newbie asks for help with mingw and libtiff", by
2005.10.17 23:16 "Re: [Tiff] newbie asks for help with mingw and libtiff", by Frank Warmerdam
2005.10.22 13:47 "[Tiff] checking test images", by ryuki_dono
2005.10.26 12:06 "Re: [Tiff] Re: checking test images", by ryuki_dono
2005.10.26 14:43 "Re: [Tiff] Re: checking test images", by Frank Warmerdam
2005.10.26 17:47 "Re: [Tiff] Re: checking test images", by ryuki_dono
2005.10.26 18:05 "Re: [Tiff] Re: checking test images", by Bob Friesenhahn
2005.10.26 18:59 "Re: [Tiff] Re: checking test images", by Joris
2005.10.26 19:47 "Re: [Tiff] Re: checking test images", by Bob Friesenhahn
2005.10.26 21:38 "Re: [Tiff] Re: checking test images", by ryuki_dono
2005.10.26 22:06 "Re: [Tiff] Re: checking test images", by Frank Warmerdam

2005.10.17 03:43 "[Tiff] newbie asks for help with mingw and libtiff", by

Hi-

I need a little help getting off the ground. Below is what is supposed to be my easy first attempt at using libtiff, but I cannot get it to link...(this should be easy?)

/* file first.c */
#include <tiffio.h>
#include <stdio.h>

main()
{
  int w,h;

  TIFF* tif = TIFFOpen("foo.tif", "r");
  TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
  TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
  TIFFClose(tif);
  printf("Width = %d\n", w);
  printf("Length = %d\n", h);
}

Here's what I did:

  1. Copied all the .h files and libraries from the libtiff default locations to c:\mingw\include c:\mingw\lib, respectively. (I know there is a right way to point the mingw compile/link process at the files in their original locations...please enlighten me!)
  2. gcc -c first.c This produces first.o, so I'm feeling pretty smug at this point.
  3. ld -o first first.0 c:\mingw\lib\libtiff.lib (third argument could be -ltiff)

This produces the following messages:

ld: warning: cannot find entry symbol _mainCRTStartup; defaulting to 00401000

first.o(.text+0x21):first.c: undefined reference to `_alloca'
first.o(.text+0x26):first.c: undefined reference to `__main'
first.o(.text+0x32):first.c: undefined reference to `printf'
first.o(.text+0x9b):first.c: undefined reference to `printf'
first.o(.text+0xae):first.c: undefined reference to `printf'

I know I am doing something simple and wrong. I'm not new to programming, but it's all Fortran or Labview. I last did serious C back in grad school (1e6 years ago). I've only installed mingw so I can use libtiff, so my problem is probably with using mingw rather than libtiff. But if anyone can take pity on me (I don't mind if you have a few chuckles at my expense!) I would be very grateful.

-Geoff Nunes

P.S. On a complete whim I tried

ld -o first first.0 -lmsvcrt -ltiff and the three undefined references to printf went away. The rest of the messages remained.