qiqian / webp

Automatically exported from code.google.com/p/webp
0 stars 0 forks source link

libpng is not correctly detected in static only builds (msys/mingw) #180

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
libwebp 0.4.0 and libpng 1.6.8, a simple "./configure --disable-shared 
--prefix=/mingw64" will fail to detect libpng (which was built as static 
libraries only as well) with the following error:

checking for libpng-config... /mingw64/bin/libpng-config
checking png.h usability... yes
checking png.h presence... yes
checking for png.h... yes
checking for library containing png_get_libpng_ver... no
configure: WARNING: Optional png library not found

The following was logged in config.log

configure:12300: checking for libpng-config
configure:12318: found /mingw64/bin/libpng-config
configure:12330: result: /mingw64/bin/libpng-config
configure:12367: checking png.h usability
configure:12367: x86_64-w64-mingw32-gcc -c -g -O2 
-I/mingw64/x86_64-w64-mingw32/include/libpng16  conftest.c >&5
configure:12367: $? = 0
configure:12367: result: yes
configure:12367: checking png.h presence
configure:12367: x86_64-w64-mingw32-gcc -E 
-I/mingw64/x86_64-w64-mingw32/include/libpng16  conftest.c
configure:12367: $? = 0
configure:12367: result: yes
configure:12367: checking for png.h
configure:12367: result: yes
configure:12369: checking for library containing png_get_libpng_ver
configure:12400: x86_64-w64-mingw32-gcc -o conftest.exe -g -O2 
-I/mingw64/x86_64-w64-mingw32/include/libpng16   conftest.c -L/mingw64/lib 
-lpng16  >&5
d:/mingw/msys/1.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x8
6_64-w64-mingw32/lib/../lib/libpng16.a(png.o): In function `png_reset_crc':
D:\MinGW\msys\1.0\home\Jamrial\libpng-1.6.8/png.c:105: undefined reference to 
`crc32'
d:/mingw/msys/1.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x8
6_64-w64-mingw32/lib/../lib/libpng16.a(png.o): In function `png_calculate_crc':
D:\MinGW\msys\1.0\home\Jamrial\libpng-1.6.8/png.c:146: undefined reference to 
`crc32'
d:/mingw/msys/1.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x8
6_64-w64-mingw32/lib/../lib/libpng16.a(png.o): In function 
`png_compare_ICC_profile_with_sRGB':
D:\MinGW\msys\1.0\home\Jamrial\libpng-1.6.8/png.c:2192: undefined reference to 
`adler32'
D:\MinGW\msys\1.0\home\Jamrial\libpng-1.6.8/png.c:2193: undefined reference to 
`adler32'
D:\MinGW\msys\1.0\home\Jamrial\libpng-1.6.8/png.c:2205: undefined reference to 
`crc32'
D:\MinGW\msys\1.0\home\Jamrial\libpng-1.6.8/png.c:2206: undefined reference to 
`crc32'
d:/mingw/msys/1.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x8
6_64-w64-mingw32/lib/../lib/libpng16.a(png.o): In function `png_reset_zstream':
D:\MinGW\msys\1.0\home\Jamrial\libpng-1.6.8/png.c:885: undefined reference to 
`inflateReset'
d:/mingw/msys/1.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x8
6_64-w64-mingw32/lib/../lib/libpng16.a(pngread.o): In function 
`png_read_destroy':
D:\MinGW\msys\1.0\home\Jamrial\libpng-1.6.8/pngread.c:874: undefined reference 
to `inflateEnd'
d:/mingw/msys/1.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x8
6_64-w64-mingw32/lib/../lib/libpng16.a(pngwrite.o): In function 
`png_write_destroy':
D:\MinGW\msys\1.0\home\Jamrial\libpng-1.6.8/pngwrite.c:862: undefined reference 
to `deflateEnd'
d:/mingw/msys/1.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x8
6_64-w64-mingw32/lib/../lib/libpng16.a(pngrutil.o): In function 
`png_inflate_claim':
D:\MinGW\msys\1.0\home\Jamrial\libpng-1.6.8/pngrutil.c:405: undefined reference 
to `inflateReset2'
D:\MinGW\msys\1.0\home\Jamrial\libpng-1.6.8/pngrutil.c:414: undefined reference 
to `inflateInit2_'
d:/mingw/msys/1.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x8
6_64-w64-mingw32/lib/../lib/libpng16.a(pngrutil.o): In function `png_inflate':
D:\MinGW\msys\1.0\home\Jamrial\libpng-1.6.8/pngrutil.c:528: undefined reference 
to `inflate'
d:/mingw/msys/1.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x8
6_64-w64-mingw32/lib/../lib/libpng16.a(pngrutil.o): In function 
`png_decompress_chunk':
D:\MinGW\msys\1.0\home\Jamrial\libpng-1.6.8/pngrutil.c:625: undefined reference 
to `inflateReset'
d:/mingw/msys/1.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x8
6_64-w64-mingw32/lib/../lib/libpng16.a(pngrutil.o): In function 
`png_inflate_read':
D:\MinGW\msys\1.0\home\Jamrial\libpng-1.6.8/pngrutil.c:777: undefined reference 
to `inflate'
d:/mingw/msys/1.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x8
6_64-w64-mingw32/lib/../lib/libpng16.a(pngrutil.o): In function 
`png_read_IDAT_data':
D:\MinGW\msys\1.0\home\Jamrial\libpng-1.6.8/pngrutil.c:4016: undefined 
reference to `inflate'
D:\MinGW\msys\1.0\home\Jamrial\libpng-1.6.8/pngrutil.c:4016: undefined 
reference to `inflate'
d:/mingw/msys/1.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x8
6_64-w64-mingw32/lib/../lib/libpng16.a(pngwutil.o): In function 
`png_deflate_claim':
D:\MinGW\msys\1.0\home\Jamrial\libpng-1.6.8/pngwutil.c:418: undefined reference 
to `deflateInit2_'
D:\MinGW\msys\1.0\home\Jamrial\libpng-1.6.8/pngwutil.c:396: undefined reference 
to `deflateEnd'
D:\MinGW\msys\1.0\home\Jamrial\libpng-1.6.8/pngwutil.c:414: undefined reference 
to `deflateReset'
d:/mingw/msys/1.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x8
6_64-w64-mingw32/lib/../lib/libpng16.a(pngwutil.o): In function 
`png_text_compress':
D:\MinGW\msys\1.0\home\Jamrial\libpng-1.6.8/pngwutil.c:581: undefined reference 
to `deflate'
d:/mingw/msys/1.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x8
6_64-w64-mingw32/lib/../lib/libpng16.a(pngwutil.o): In function 
`png_compress_IDAT':
D:\MinGW\msys\1.0\home\Jamrial\libpng-1.6.8/pngwutil.c:1055: undefined 
reference to `deflate'
collect2.exe: error: ld returned 1 exit status

The problem seems to be that configure is calling libpng-config without 
--static in this scenario (Needed to link with zlib).

I would also recommend you to not call "libpng-config --prefix" followed by 
"libpng-config --libs" to generate the library path, and instead use the output 
of "libpng-config --ldflags" (preceded by --static if necessary).

Original issue reported on code.google.com by jamr...@gmail.com on 2 Jan 2014 at 9:14

GoogleCodeExporter commented 8 years ago
I had the same problem under a Cygwin environment w/ Mingw as a compiler, I 
bypassed the script detection like this:

ac_cv_search_png_get_libpng_ver="none required" 
LIBPNG_CONFIG=/mingw64/bin/libpng-config ./configure  (...)

Original comment by zebo...@gmail.com on 3 Jan 2014 at 1:26

GoogleCodeExporter commented 8 years ago

Original comment by pascal.m...@gmail.com on 19 Aug 2014 at 12:49

GoogleCodeExporter commented 8 years ago
There are a few issues here:
1) the suggestion for --ldflags over --prefix + --libs
2) it wasn't clear, but it seemed like the expectation was that 
'--disable-shared' would modify this check (and presumably control static 
linking of the binaries).

(1) seems reasonable.

For (2) it would be better to define another option rather than overload 
'--disable-shared' which is meant to control the generation of shared object 
files. This is a somewhat uncommon case and can be done currently with 
--with-pnglibdir/--with-pngincludedir, these will override the libpng-config 
check.

Original comment by jz...@google.com on 9 Sep 2014 at 10:53