Skip to content

Building libpng apng

Kalvin Harlan edited this page Jun 20, 2021 · 8 revisions

We support the new animated PNG format, but this requires some custom building to get the functionality we need. Specifically, we need to patch an existing release of libpng to add the animated PNG support.

Linux

We have an automated script to help you download and build the latest libpng-apng!

Before running this script, make sure you have a compiler installed (GCC/Clang), as well as the zlib development files installed. If you're not sure how, search online for "YOUR_DISTRO_NAME install c compiler" and "YOUR_DISTRO_NAME install zlib dev" for instructions. (We wish we could be more specific, but there are too many distros out there to cover here!)

  1. Open a terminal and navigate to the CEmu source tree. (e.g. cd ~/Downloads/CEmu)
  2. Run: cd ./gui/qt/capture && ./get_libpng-apng.sh
  3. Follow any directions needed on the screen - enjoy!

Mac OS X

We have an automated script to help you download and build the latest libpng-apng! Note that for this to work, you may need to XCode and/or pkg-config (from brew).

  1. Open Terminal and navigate to the CEmu source tree. (e.g. cd ~/Downloads/CEmu)
  2. Run: cd ./gui/qt/capture && ./get_libpng-apng.sh
  3. Follow any directions needed on the screen - enjoy!

Windows

There are two ways you can build libpng-apng: either with MinGW/MSYS2, or with MSVC.

If you are using MinGW/MSYS2, follow the steps above for Linux, substituting as necessary.

If you are using MSVC, these are the steps for you!

For all steps requiring downloading and extracting, make sure to download and extract them into the same directory. You can use 7-zip to extract the files necessary for building.

  1. Download and extract the latest libpng release from here.

  2. Download and extract the patch that matches the version you've downloaded here. Note that if a patch is not available for the version you've selected, you should re-do step #1 with the latest version you see here.

  3. Download and extract the latest zlib release from here.

  4. Download the patch binaries from here. Extract the entirety to a folder that you know about (e.g. C:\Users\USER\Downloads).

  5. Open a Command Prompt and enter the directory where you have your extracted libpng release. (e.g. cd C:\libpng-1.6.34)

  6. Type in this command, and make sure it completes successfully: C:\full_path_to\patch.exe -Np1 -i path_to_patch If this fails, make sure you are within the libpng source tree.

  7. Now enter your libpng-x.x.x/projects/vstudio/ directory. Inside there should be a zlib.props file - edit this to point to the correct zlib-x.x.x folder. (If you put everything into the same folder, this should be easy to edit!)

  8. Now open vstudio.sln. If you're using a newer version of Visual Studio, it will ask you to upgrade. Simply say yes.

  9. ONLY IF YOU WANT 64-BIT BUILDS: Follow these steps on each project to enable x64 builds. Make sure to follow "To copy Win32 project settings into a 64-bit project configuration" to copy the appropriate settings over.

  10. Now you have two choices - you can either build everything directly within the Visual Studio GUI, or you can run it via MSBuild.

    • If you decide to use the GUI, just pick the configuration you want to build and hit Build (play icon). Everything should start building from there.

    • If you decide to use MSBuild, make sure to source the vcvarsall.bat script from the MSVC directory. (Alternatively, you can just use the MSBuild Command Prompt, found in your Start Menu.) Once you're in, simply type msbuild vstudio.sln /p:Configuration="CONFIG" to get things going. Note that you will need to use the appropriate environment for setting the build architecture, e.g. running vcvarsall.bat x64 to get 64-bit building support. You may also need /p:Platform="x86" as well.

    • Targets include Release/Debug and Release/Debug Library. Release/Debug will build a DLL, and Release/Debug Library will build a static library. Note that build configurations should match across the whole build process - if you want to build CEmu statically in release mode, you will need a static release of libpng/zlib, as well as a static release of Qt.

  11. Once you are done building, copy your *.lib, *.dll, and *.pdb files to a location where you want to store your libpng-apng libraries (e.g. C:\libpng-apng\lib). Include the zlib files as well - you WILL need these!

  12. Copy png.h, pngconf.h, and pngpriv.h to a location where you want to store your libpng-apng includes (e.g. C:\libpng-apng\include).

  13. That's it - you're done! For MSVC builds of CEmu, you will need to set the following environment variables for QMake/Qt Creator: LIBPNG_APNG_LIB, ZLIB_LIB, and LIBPNG_APNG_INCLUDE, pointing to their respective folders.