pngpp-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[pngpp-devel] Re: Problems on static compilition using PNG++


From: Alexander Shulgin
Subject: [pngpp-devel] Re: Problems on static compilition using PNG++
Date: Tue, 16 Dec 2008 09:01:13 +0200

On Tue, Dec 16, 2008 at 2:40 AM, Joan Puigcerver <address@hidden> wrote:
> Hi!
> I was trying to compile a little program I wrote using the static option and
> I get some errors from GCC. I'm not sure if it's a problem from your
> wrapper, from LibPNG or from my source. Here's the compilation output:
>>
>> $ make
>> g++ -c pngimage.cpp `libpng-config --cflags` -Wall -pedantic -static
>> g++ -c wodax.cpp -DMAX_PASS=500 -Wall -pedantic -static
>> g++ -o wodax pngimage.o wodax.o `libpng-config --ldflags` -Wall -pedantic
>> -static
>> /usr/lib/libpng12.a(libpng12_la-png.o): In function `png_calculate_crc':
>> (.text+0xb09): undefined reference to `crc32'
>> /usr/lib/libpng12.a(libpng12_la-png.o): In function `png_reset_crc':
>> (.text+0xb3b): undefined reference to `crc32'
>> /usr/lib/libpng12.a(libpng12_la-png.o): In function `png_reset_zstream':
>> (.text+0x8d): undefined reference to `inflateReset'
>> /usr/lib/libpng12.a(libpng12_la-pngread.o): In function `png_read_row':
>> (.text+0x4b9): undefined reference to `inflate'

Hi,

the problem is not with png++ or libpng.  If you try this:

$ cat testlibpng-static.c
#include <png.h>

int
main(void)
{
        png_create_read_struct(NULL, NULL, NULL, NULL);
        return 0;
}
$ gcc testlibpng-static.c `libpng-config --ldflags` -static
/usr/lib/libpng12.a(libpng12_la-pngread.o): In function `png_read_row':
(.text+0x587): undefined reference to `inflate'
/usr/lib/libpng12.a(libpng12_la-pngread.o): In function
`png_create_read_struct_2':
(.text+0x17ec): undefined reference to `inflateInit_'
/usr/lib/libpng12.a(libpng12_la-pngread.o): In function `png_read_destroy':
(.text+0x1c42): undefined reference to `inflateEnd'
/usr/lib/libpng12.a(libpng12_la-pngread.o): In function `png_read_init_3':
(.text+0x1f51): undefined reference to `inflateInit_'
/usr/lib/libpng12.a(libpng12_la-pngrtran.o): In function
`png_build_gamma_table':
(.text+0x27e9): undefined reference to `pow'
...

Obviously, when you do -static, libpng no longer pulls zlib in, so you
should add it explicitly:
$ gcc testlibpng-static.c `libpng-config --ldflags` -static -lz
/usr/lib/libpng12.a(libpng12_la-pngrtran.o): In function
`png_build_gamma_table':
(.text+0x27e9): undefined reference to `pow'
/usr/lib/libpng12.a(libpng12_la-pngrtran.o): In function
`png_build_gamma_table':
(.text+0x29d2): undefined reference to `pow'
...

This is better, but still no ideal ;)  Just add -lm to pull in the math library:

$ gcc testlibpng-static.c `libpng-config --ldflags` -static -lz -lm
$

Voila!

--
Cheers,
Alex




reply via email to

[Prev in Thread] Current Thread [Next in Thread]