This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc and libtiff, maybe a newbie question


The problem is partially due to where the -lname bits are. They should
be put at the end of the line (after all options and stuff). You also
needed to include libz (-lz) and libjpeg (-ljpeg).

This worked for me:

$ gcc -static -o tifft tifft.c -lm -ltiff -ljpeg -lz

P.s. I renamed your file to tifft.c, still using your code.


--- "Henrik Bengtsson" <> wrote:
>Hi, first I haven't done C programming in years and am a bit rusty with
>gcc and ld. I am having problems with ld reporting "undefined reference
>to _TIFFOpen" etc, which should be in libtiff. However, I am not even
>sure if the problem is about libtiff or if miss something else.
>Here is my minimize code I am trying to compile and link (write.c):
>#include <stdio.h>
>#include "tiff.h"
>#include "tiffio.h"
>int main(int argc, char *argv[]) {
>  TIFF *image;
>  if((image = TIFFOpen("output.tif", "w")) == NULL){
>    printf("Could not open output.tif for writing\n");
>    exit(42);
>  }
>  TIFFClose(image);
>I get the following error:
>% gcc -static -lm -ltiff -o write.o -ltiff write.c
>/tmp/ccfugoHj.o(.text+0x76):write.c: undefined reference to `_TIFFOpen'
>/tmp/ccfugoHj.o(.text+0xa2):write.c: undefined reference to `_TIFFClose'
>collect2: ld returned 1 exit status
>According to the following troubleshooting it looks like it finds
>libtiff.a (or something):
>% gcc -static -lm -ltiffX -o write.o -ltiff write.c
>cannot fi
>nd -ltiffX
>collect2: ld returned 1 exit status
>According to Cygwin Setup the tiff version is 3.5.7-1. gcc is v3.2
>% ls -l /usr/lib/libtiff.*
>-rwx------+   1 hb       None       316100 Feb 10  2002
>-rwx------+   1 hb       None       152620 Feb 10  2002
>% ls -l /usr/include/tiff*
>-rwx------+   1 hb       None        24302 Feb 10  2002
>-rwx------+   1 hb       None         5254 Feb 10  2002
>-rwx------+   1 hb       None        14072 Feb 10  2002
>-rwx------+   1 hb       None        11554 Feb 10  2002
>-rwx------+   1 hb       None          410 Feb 10  2002
>I appreciate any help. 
>Henrik Bengtsson
>Unsubscribe info:
>Bug reporting:

_____________________________________________________________ - Free UK Internet Services

Select your own custom email address for FREE! Get w/No Ads, 6MB, POP & more!

Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]