[英]MinGW/msys, linker (ld.exe) not finding libpng (-lpng) even though it's installed, running xpdf configure script
I installed versions 1.2, 1.4, and 1.6 of libpng from source from the makefiles they include for MinGW/msys. 我从他们为MinGW / msys包含的makefile中安装了源自libpng的版本1.2,1.4和1.6。 It seemed to work - I've got the header files in various places:
它似乎工作 - 我有各种地方的头文件:
As well as library files: 以及库文件:
I call the configure script with msys's bash, and it chokes in the same place no matter what combination of include directory and library I feed it. 我用msys的bash调用configure脚本,无论include目录和库的组合是什么,它都会在同一个地方窒息。 Config.log gives me the following:
Config.log给了我以下内容:
configure:7732: checking png.h usability
configure:7732: gcc -c -g -O2 -I/local/include conftest.c >&5
configure:7732: $? = 0
configure:7732: result: yes
configure:7732: checking png.h presence
configure:7732: gcc -E -I/local/include conftest.c
configure:7732: $? = 0
configure:7732: result: yes
configure:7732: checking for png.h
configure:7732: result: yes
configure:7761: checking for png_write_row in -lpng
configure:7786: gcc -o conftest.exe -g -O2 conftest.c -lpng -I/local/include /local/lib/libpng.a -lz >&5
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: cannot find -lpng
collect2.exe: error: ld returned 1 exit status
I've tried every combination of include directory and library listed above, and it's the same, every time. 我已经尝试过上面列出的include目录和库的每个组合,每次都是一样的。 It will be
这将是
configure:7786: gcc -o conftest.exe -g -O2 conftest.c -lpng -I/include/libpng /lib/libpng.dll.a -lz >&5
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: cannot find -lpng
or 要么
configure:7786: gcc -o conftest.exe -g -O2 conftest.c -lpng -I/local/include/libpng16 /local/lib/libpng16.dll -lz >&5
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: cannot find -lpng
or 要么
configure:7786: gcc -o conftest.exe -g -O2 conftest.c -lpng -I/include/libpng12 /lib/libpng12.a -lz >&5
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: cannot find -lpng
You get the picture. 你得到了照片。 I've successfully compiled several other xpdf pieces that don't require libpng.
我已成功编译了其他几个不需要libpng的xpdf片段。 But here, I'm at a total loss.
但在这里,我完全失去了。
Try this: 尝试这个:
png.h
header for MinGW targets is incompatible with the png.h
header for Cygwin targets.) png.h
为MinGW的目标首标是与不相容png.h
报头Cygwin的目标。) mingw64-*-libpng
packages in Cygwin do not provide a static libpng.a
library, which is unusual.) mingw64-*-libpng
包不提供静态的libpng.a
库,这很不寻常。) For example, for a 64-bit build: 例如,对于64位版本:
$ export CC=x86_64-w64-mingw32-gcc
$ export CXX=x86_64-w64-mingw32-g++
$ export PATH="/usr/x86_64-w64-mingw32/sys-root/mingw/bin:$PATH"
$ export CFLAGS="-L/usr/x86_64-w64-mingw32/sys-root/mingw/lib -I/usr/x86_64-w64-mingw32/sys-root/mingw/include -lpng -Wl,Bdynamic"
$ export CXXFLAGS="$CFLAGS"
$ which libpng-config
/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libpng-config
$ ./configure
EDIT: Adding the redist folder to the PATH before compile time, which contains the libpng.dll file, is the important non-obvious step that applies to both the Cygwin and MSYS environments. 编辑:在编译时将redist文件夹添加到PATH,其中包含libpng.dll文件,是适用于Cygwin和MSYS环境的重要非显而易见的步骤。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.