Skip to content

PNG Library Setup (Requires GTK 4, JPEG Lib)

VerzatileDev edited this page Aug 31, 2023 · 1 revision

The following library in this Setup requires that GTK 4 / MSYS2 Terminal / JpegLib is installed!

To install and get png.h open the msys2:

  1. Update existing packages > pacman -Syu
  2. Add libpng library > pacman -S mingw-w64-x86_64-libpng
  3. Make sure the following are installed in the terminal

" libgpgme-1.22.0-1 mingw-w64-x86_64-gtk4-4.12.1-1 mingw-w64-x86_64-sqlite3-3.43.0-1 mpfr-4.2.1-1 mingw-w64-x86_64-libpng"

  1. In your .vscode c_cpp_properties.json , add the following :
{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:/msys64/mingw64/include/gtk-4.0",
                "C:/msys64/mingw64/include/glib-2.0",
                "C:/msys64/mingw64/include/**",
                "C:/msys64/mingw64/lib/**",
                "${workspaceFolder}/src/converters",
                "C:/msys64/mingw64/include/libpng16"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.22000.0",
            "compilerPath": "C:/msys64/mingw64/bin/gcc.exe",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-gcc-x64"
        }
    ],
    "version": 4
  }
  • Note that it additionally added "C:/msys64/mingw64/include/libpng16", directory!¬
  1. Tasks.json Add :
{
	"version": "2.0.0",
	"tasks": [
	   {
		  "type": "cppbuild",
		  "label": "C/C++: gcc.exe build active file",
		  "command": "C:/msys64/mingw64/bin/gcc.exe",
		  "args": [
			"-fdiagnostics-color=always",
			"-g",
			"-IC:/msys64/mingw64/include/gtk-4.0",
			"-IC:/msys64/mingw64/include/pango-1.0",
			"-IC:/msys64/mingw64/include",
			"-IC:/msys64/mingw64/include/glib-2.0",
			"-IC:/msys64/mingw64/lib/glib-2.0/include",
			"-IC:/msys64/mingw64/include/harfbuzz",
			"-IC:/msys64/mingw64/include/freetype2",
			"-IC:/msys64/mingw64/include/libpng16",
			"-IC:/msys64/mingw64/include/fribidi",
			"-IC:/msys64/mingw64/include/cairo",
			"-IC:/msys64/mingw64/include/pixman-1",
			"-IC:/msys64/mingw64/include/gdk-pixbuf-2.0",
			"-IC:/msys64/mingw64/include/webp",
			"-DLIBDEFLATE_DLL",
			"-IC:/msys64/mingw64/include/graphene-1.0",
			"-IC:/msys64/mingw64/lib/graphene-1.0/include",
			"-mfpmath=sse",
			"-msse",
			"-msse2",
			"${file}",
			"-o",
			"${fileDirname}/converters/bmp_to_jpeg.exe",
			"-LC:/msys64/mingw64/lib",
			"-lgtk-4",
			"-lpangowin32-1.0",
			"-lpangocairo-1.0",
			"-lpango-1.0",
			"-lharfbuzz",
			"-lgdk_pixbuf-2.0",
			"-lcairo-gobject",
			"-lcairo",
			"-lgraphene-1.0",
			"-lgio-2.0",
			"-lgobject-2.0",
			"-lglib-2.0",
			"-lintl",
			"-ljpeg",
			"-lpng",
			"-o",
			"${fileDirname}/${fileBasenameNoExtension}.exe"
		 ],
		  "options": {
			 "cwd": "C:/msys64/mingw64/bin"
		  },
		  "problemMatcher": [
			 "$gcc"
		  ],
		  "group": "build",
		  "detail": "compiler: C:/msys64/mingw64/bin/gcc.exe"
	   }
	]
}
  • Note that the Tasks.json added in "-lpng" flag
Clone this wiki locally