AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
October 2005

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2005.10.17 03:43 "newbie asks for help with mingw and libtiff", by <gnunes5@comcast.net>
2005.10.17 23:16 "Re: newbie asks for help with mingw and libtiff", by Frank Warmerdam

2005.10.17 03:43 "newbie asks for help with mingw and libtiff", by <gnunes5@comcast.net>

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.