Colin Law clanlaw at
Thu Apr 4 06:51:36 UTC 2013

On 3 April 2013 22:49, Dieter Wirz <didi.wirz at> wrote:
> Hi -
> I'm trying to compile a simple program using libpng.
> The Program looks similar to this one:
> dw at dw-UX31E:~/libpng$ sudo apt-get install libpng-dev
> Reading package lists... Done
> Building dependency tree
> Reading state information... Done
> Note, selecting 'libpng12-dev' instead of 'libpng-dev'
> libpng12-dev is already the newest version.
> 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
> dw at dw-UX31E:~/libpng$ gcc -Wall -lpng -lm mand.c -o mand
> mand2.c: In function ‘createImage’:
> mand2.c:209:14: warning: variable ‘dch0’ set but not used
> [-Wunused-but-set-variable]
> mand2.c:209:8: warning: variable ‘dtime’ set but not used
> [-Wunused-but-set-variable]
> /tmp/cc45bIi0.o: In function `writeImage':
> mand2.c:(.text+0x17e): undefined reference to `png_create_write_struct'

Have you had a look in png.h to see if the methods are there?  If they
appear to be there then rename it and make sure  you then get a file
not found error.  That will prove that you are including the png.h
that you think you are.  Perhaps it is pulling in a png.h from
somewhere else.


> mand2.c:(.text+0x1c1): undefined reference to `png_create_info_struct'
> mand2.c:(.text+0x243): undefined reference to `png_init_io'
> mand2.c:(.text+0x282): undefined reference to `png_set_IHDR'
> mand2.c:(.text+0x2b9): undefined reference to `png_set_text'
> mand2.c:(.text+0x2cc): undefined reference to `png_write_info'
> mand2.c:(.text+0x358): undefined reference to `png_write_row'
> mand2.c:(.text+0x375): undefined reference to `png_write_end'
> mand2.c:(.text+0x3a9): undefined reference to `png_free_data'
> mand2.c:(.text+0x3c3): undefined reference to `png_destroy_write_struct'
> collect2: error: ld returned 1 exit status
> dw at dw-UX31E:~/libpng$
> What am I missing?
> (BTW: The program compiles without any issues on an ARM-Archlinux....)
> Dieter
> --
> ubuntu-users mailing list
> ubuntu-users at
> Modify settings or unsubscribe at:

More information about the ubuntu-users mailing list