简体   繁体   English

MinGW / msys,链接器(ld.exe)找不到libpng(-lpng),即使它已经安装,运行xpdf configure脚本

[英]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: 它似乎工作 - 我有各种地方的头文件:

  • /include /包括
  • /include/libpng /有/的libpng
  • /include/libpng12 /有/填实:libpng12
  • /include/libpng14 /有/ libpng14
  • /local/include /本地/包括
  • /local/include/libpng /本地/包括/的libpng
  • /local/include/libpng16 /本地/包括/ libpng16

As well as library files: 以及库文件:

  • /lib/libpng.a /lib/libpng.a
  • /lib/libpng.dll.a /lib/libpng.dll.a
  • /lib/libpng12.a /lib/libpng12.a
  • /lib/libpng12.dll.a /lib/libpng12.dll.a
  • /lib/libpng14.a /lib/libpng14.a
  • /lib/libpng14.dll.a /lib/libpng14.dll.a
  • /local/lib/libpng.a /local/lib/libpng.a
  • /local/lib/libpng.dll /local/lib/libpng.dll
  • /local/lib/libpng16.a /local/lib/libpng16.a
  • /local/lib/libpng16.dll /local/lib/libpng16.dll

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: 尝试这个:

  1. Add the MinGW redist to the path. 将MinGW redist添加到路径中。
  2. Ensure that the MinGW library and include paths precede those of Cygwin. 确保MinGW库和包含路径先于Cygwin的路径。 (The png.h header for MinGW targets is incompatible with the png.h header for Cygwin targets.) (该png.h为MinGW的目标首标是与不相容png.h报头Cygwin的目标。)
  3. Dynamically link libpng. 动态链接libpng。 (The mingw64-*-libpng packages in Cygwin do not provide a static libpng.a library, which is unusual.) (Cygwin中的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.

相关问题 msys / MinGW,即使已安装,也找不到libpng,试图编译xpdf(特别是pdftopng) - msys/MinGW, can't find libpng even though it's installed, trying to compile xpdf (specifically pdftopng) 如何消除链接器错误 mingw32/bin/ld.exe: 找不到 -lSDL - how do I eliminate linker error mingw32/bin/ld.exe: cannot find -lSDL MinGW / Eclipse ld.exe找不到库 - MinGW/Eclipse ld.exe does not find libraries /Mingw32/bin/ld.exe:找不到-llibcurl? - /Mingw32/bin/ld.exe: cannot find -llibcurl? MinGW - ld.exe 在链接 SFML 静态库时崩溃 - MinGW - ld.exe crashes while linking SFML static libraries mingw32/bin/ld.exe ... 对 [class] 的未定义引用 ... collect2.exe:错误:ld 返回 1 个退出状态 - mingw32/bin/ld.exe ... undefined reference to [class] ... collect2.exe: error: ld returned 1 exit status mingw32/bin/ld.exe:找不到 -lfl collect2.exe:错误:ld 返回 1 个退出状态 - mingw32/bin/ld.exe: cannot find -lfl collect2.exe: error: ld returned 1 exit status \\ mingw-w64 \\…\\ ld.exe:找不到-lboost_filesystem - \mingw-w64\ … \ld.exe: cannot find -lboost_filesystem Windows 7上的Cygwin G ++链接器(ld.exe)找不到libc.so.6和其他库文件 - Cygwin G++ linker (ld.exe) on Windows 7 cannot find libc.so.6 and other library files ld.exe 找不到 -lGL - ld.exe cannot find -lGL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM