简体   繁体   English

如何为Windows构建和链接libpng

[英]How to build and link libpng for Windows

I am trying to build and link libpng so that I can I use it with Eclipse, C++, and Windows 8.1 (64 bit). 我正在尝试构建和链接libpng,以便可以在Eclipse,C ++和Windows 8.1(64位)中使用它。

I'm using the GCC C++ compiler with options: 我正在使用带有选项的GCC C ++编译器:

-I"C:\\zlib-1.2.8" -I"C:\\lpng1625" -I"C:\\CImg\\CImg-1.7.5" -O0 -g3 -Wall -c -fmessage-length=0 -Dcimg_use_png -lpng16 -v -I“ C:\\ zlib-1.2.8” -I“ C:\\ lpng1625” -I“ C:\\ CImg \\ CImg-1.7.5” -O0 -g3-墙-c -fmessage-length = 0 -Dcimg_use_png -lpng16 -v

And the MinGW C++ linker with options: 以及带有选项的MinGW C ++链接器:

-L"C:\\lpng1625" -L"C:\\zlib-1.2.8" and libraries are set to: gdi32, z, and png1625. -L“ C:\\ lpng1625” -L“ C:\\ zlib-1.2.8”并将库设置为:gdi32,z和png1625。

I've also tried variants of png16, png15, and png15. 我还尝试了png16,png15和png15的变体。

My error message is: "Cannot find -lpng1625" 我的错误消息是:“找不到-lpng1625”

Do I need to build libpng? 我需要构建libpng吗? If so, how can I do this? 如果是这样,我该怎么做?

I got it to work by using Visual Studio 15 and the NuGet package manager. 我通过使用Visual Studio 15和NuGet程序包管理器使其工作。

NuGet made it very easy to install libpng (and automatically installed its dependencies including zlib). NuGet使安装libpng非常容易(并自动安装了其依赖项,包括zlib)。 Next I included Cimg.h by adding its directory under the project properties and "Include Directories". 接下来,我通过在项目属性和“包含目录”下添加其目录来包含Cimg.h。 Finally I had to install GraphicsMagick so that CImg could save PNG files. 最后,我必须安装GraphicsMagick,以便CImg可以保存PNG文件。 I did this by downloading the windows binary. 我通过下载Windows二进制文件来做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM