Dev-C++: Can anyone please compile this?

This is a discussion on Dev-C++: Can anyone please compile this? within the C Programming forums, part of the General Programming Boards category; Hey, not to be a bother, but Ive tried compiling this into an executable using Dev-C++ and get 4 undefined ...

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    45

    Unhappy Dev-C++: Can anyone please compile this?

    Hey, not to be a bother, but Ive tried compiling this into an executable using Dev-C++ and get 4 undefined errors im stuck at. Something with the Large File System functions, and cant get around it

    Since Im in a hurry, im hoping maybe someone here could compile it for me?

    You need:

    zlib, libjpeg and libtiff.

    All are in Dev-C++ Packs for easy installing. Once installed, link them using the project options -> parameters. The code is as follows:
    Code:
    #include <stdio.h>
    #include <unistd.h>
    #include "tiffio.h"
    #include <sys/stat.h>
    
    int debug;
    
    /* for RGB image create three output files with these extensions */
    char *color[3] = { "red", "grn", "blu" };
    
    char text[80];
    FILE *ofp[3];
    unsigned char *obuf[3];
    
    void usage(char *s)
    {
        fprintf(stderr, "Usage: %s [-d] input-TIFF-file output-raw-file\n", s);
    }
    
    int main(int argc, char *argv[])
    {
        char c;
        int errflg;
        extern int optind;
        extern char *optarg;
        TIFF* tif;
        uint32 width, height, *raster, *p;
        uint16 depth;
        size_t npixels;
        int i;
        uint32 x, y, z;
        unsigned char *pr, *pg, *pb;
    
        debug = errflg = 0;
    
        while ((c = getopt(argc,argv,"d")) != EOF)
    	switch (c) {
    	  case 'd':
    	    debug = 1;
    	    break;
    	  case '?':
    	    errflg = 1;
    	    break;
    	}
        if (errflg) {
    	usage(argv[0]);
    	exit(1);
        }
    
        if (optind < argc) {
    	if ((tif = TIFFOpen(argv[optind], "r")) == NULL) {;
    	    fprintf(stderr, "Can't open input file \"%s\"\n", argv[optind]);
    	    exit(1);
    	}
    	optind++;
        }
        else {
    	fprintf(stderr, "Must specify input file\n");
    	usage(argv[0]);
    	exit(1);
        }
    
        TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width);
        TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height);
        npixels = width * height;
    
        /* See if this is a color or gray image */
        TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &depth);
        if (depth == 3) {		/* RGB color image */
    	if (optind < argc) {
                for (i = 0; i < 3; i++) {
                    if ((obuf[i] = (unsigned char *) malloc(width)) == NULL) {
                        fprintf(stderr, "Can't malloc output buffer\n");
    		    TIFFClose(tif);
                        exit(1);
                    }
    		/* Use the output file name as the basename for the file
    		   and add extensions for each color */
                    sprintf(text, "%s.%s", argv[optind], color[i]);
                    if ((ofp[i] = fopen(text, "w")) == NULL) {
                        fprintf(stderr, "Can't open %s for output\n", text);
    		    TIFFClose(tif);
                        exit(1);
                    }
                }
    	}
    	else {
    	    fprintf(stderr, "Must specify output file for color output\n");
    	    TIFFClose(tif);
    	    exit(1);
    	}
        }
        else if (depth == 1) {
    	if ((obuf[0] = (unsigned char *) malloc(width)) == NULL) {
    	    fprintf(stderr, "Can't malloc output buffer\n");
    	    TIFFClose(tif);
    	    exit(1);
    	}
    	if (optind < argc) {
                if ((ofp[0] = fopen(argv[optind], "w")) == NULL) {
                    fprintf(stderr, "Can't open %s for output\n", argv[optind]);
    		TIFFClose(tif);
                    exit(1);
                }
    	}
    	else
    	    ofp[0] = stdout;
        }
        else {
    	fprintf(stderr, "Unrecognized image depth = %d\n");
    	TIFFClose(tif);
    	exit(1);
        }
    
        if (debug)
    	printf("%d x %d x %d = %d pixels\n", width, height, depth, npixels);
    
        raster = (uint32*) _TIFFmalloc(npixels * sizeof (uint32));
        if (raster != NULL) {
    	if (TIFFReadRGBAImageOriented(tif, width, height, raster,
    				      ORIENTATION_TOPLEFT, 0)) {
    	    if (depth == 3) {
    		p = raster;
    		for (y = 0; y < height; y++) {
    		    pr = obuf[0];
    		    pg = obuf[1];
    		    pb = obuf[2];
    		    for (x = 0; x < width; x++) {
    			z = *p++;
    			*pr++ = TIFFGetR(z);
    			*pg++ = TIFFGetG(z);
    			*pb++ = TIFFGetB(z);
    		    }
    		    for (i = 0; i < 3; i++)
    			fwrite(obuf[i], 1, width, ofp[i]);
    		}
    	    }
    	    else {		/* depth must be 1 */
    		p = raster;
    		for (y = 0; y < height; y++) {
    		    pr = obuf[0];
    		    for (x = 0; x < width; x++) {
    			z = *p++;
    			*pr++ = TIFFGetR(z);
    		    }
    		    fwrite(obuf[0], 1, width, ofp[0]);
    		}
    	    }
    	}
    	_TIFFfree(raster);
        }
        TIFFClose(tif);
        exit(0);
    }
    Sorry for length :-S

    That's just a copy&paste job, with a little bit of mouse clicking... I really hope someone compiles this for me, as Ive been trying to, but can't get by this little problem when compiling... Once you've compiled it, to save both time and email storage, could you please upload it onto these forums in whatever compression method you want. If it's not too much trouble, including the source as well would be cool too. No need for special project names or anything, unless you want to.

    As I said, Im in a little bit of a rush, so if someone would please compile this, thank you so much.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    So where are your errors? You apparently neglected to include them in your haste. No one wants to install a whole bunch of ........ just to help you out, when all you have to do is copy-paste your errors in.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Jun 2006
    Posts
    45
    Code:
      [Linker error] undefined reference to `__fxstat64' 
      [Linker error] undefined reference to `__fxstat64' 
      [Linker error] undefined reference to `mmap64' 
      [Linker error] undefined reference to `munmap'
    I was kind of directing the request towards Dev-C++ users, so no real need to install a bunch of .... if they already have it.

    Anyway, any idea on the error? No doubt a linking error.

  4. #4
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    first, are you sure tiffio.h is a C library?
    second, have you tried <tiffio.h>?

    Dev-C++ usually knows where it's own files are... unless you dumped all that in the same directory as your own program...
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I don't think Dev C++ has sys/stat.h. I could be wrong, but that's what your errors are pointing towards. The functions it can't find are all unix functions.

    You lose, windows user. Or if you prefer: you use windows, loser.


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    hehe I likey... yeah, the only problems I had were all related to that file... then again I'm using linux

    Code:
    xxxxx@MCP ~/Programming/C++ $ gcc test.c
    /tmp/ccS9Rn5G.o: In function `main':
    test.c:(.text+0xde): undefined reference to `TIFFOpen'
    test.c:(.text+0x16e): undefined reference to `TIFFGetField'
    test.c:(.text+0x188): undefined reference to `TIFFGetField'
    test.c:(.text+0x1ac): undefined reference to `TIFFGetField'
    test.c:(.text+0x217): undefined reference to `TIFFClose'
    test.c:(.text+0x2ac): undefined reference to `TIFFClose'
    test.c:(.text+0x2e2): undefined reference to `TIFFClose'
    test.c:(.text+0x332): undefined reference to `TIFFClose'
    test.c:(.text+0x3ae): undefined reference to `TIFFClose'
    /tmp/ccS9Rn5G.o:test.c:(.text+0x3e6): more undefined references to `TIFFClose' follow
    /tmp/ccS9Rn5G.o: In function `main':
    test.c:(.text+0x432): undefined reference to `_TIFFmalloc'
    test.c:(.text+0x46f): undefined reference to `TIFFReadRGBAImageOriented'
    test.c:(.text+0x5ed): undefined reference to `_TIFFfree'
    test.c:(.text+0x5f8): undefined reference to `TIFFClose'
    collect2: ld returned 1 exit status
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  7. #7
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    I don't think Dev C++ has sys/stat.h.
    My version of it does.

    [edit] Dev-C++ isn't officially supported, but perhaps you just need to link with the library: http://www.asmail.be/msg0054670728.html [/edit]
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compile problem on linux
    By cnb in forum C Programming
    Replies: 3
    Last Post: 09-29-2008, 04:14 AM
  2. auto_ptr assignment compile error
    By George2 in forum C++ Programming
    Replies: 7
    Last Post: 04-01-2008, 02:44 AM
  3. Compile as you type
    By Rocketmagnet in forum A Brief History of Cprogramming.com
    Replies: 33
    Last Post: 12-07-2006, 12:36 PM
  4. Dev C++ Won't Compile
    By mburt in forum Windows Programming
    Replies: 8
    Last Post: 08-21-2006, 11:14 PM
  5. Compile crashes certain windows
    By Loduwijk in forum C++ Programming
    Replies: 5
    Last Post: 03-26-2006, 08:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21