Compilation Instructions (Windows) - ThioJoe/jpeg2png GitHub Wiki
Windows Build Instructions for jpeg2png (32-bit and 64-bit)
Prerequisites
-
Install MSYS2 from https://www.msys2.org/
- It will install various different terminals for compiling in different modes. If you want you can read more about them here.
- After installation, MSYS2 might open a "UCRT64" terminal by default - close this and open "MSYS2 MSYS" from the Start menu instead
-
Initial Setup (run in MSYS2 MSYS terminal - NOT UCRT64 or CLANG64):
# Update package database and core packages pacman -Syu # After updates complete, close and reopen the MSYS2 MSYS terminal, then: pacman -Su # Install core development tools and Clang toolchain pacman -S --needed base-devel mingw-w64-clang-x86_64-toolchain # for 64-bit # OR pacman -S --needed base-devel mingw-w64-clang-i686-toolchain # for 32-bit # Verify installation worked by closing and reopening CLANG terminal and running: make --version
Installing Dependencies
After installing the toolchains, open the appropriate terminal based on your target architecture:
- For 64-bit: Use "MSYS2 CLANG64" terminal
- For 32-bit: Use "MSYS2 CLANG32" terminal
Then install the required packages:
# For 64-bit builds (in CLANG64 terminal)
pacman -S mingw-w64-clang-x86_64-libjpeg-turbo
pacman -S mingw-w64-clang-x86_64-libpng
pacman -S mingw-w64-clang-x86_64-llvm-openmp
# For 32-bit builds (in CLANG32 terminal)
pacman -S mingw-w64-clang-i686-libjpeg-turbo
pacman -S mingw-w64-clang-i686-libpng
pacman -S mingw-w64-clang-i686-llvm-openmp
Building
-
Open the appropriate MSYS2 terminal:
- For 64-bit builds: Use "MSYS2 CLANG64" terminal
- For 32-bit builds: Use "MSYS2 CLANG32" terminal
-
Navigate to the jpeg2png directory
- You can just use
cd
following by the directory, BUT you should replace any backslashes (\
) in the path with forward slashes (/
) like:cd C:\Users\WhateverUsername\Desktop\jpeg2png
- You can just use
-
Set static linking flag:
export LDFLAGS="-static"
- Build the project:
# For standard build
make CC=clang
# For Windows-specific build (includes icon)
make WINDOWS=1 CC=clang
The resulting executable will be:
- 64-bit when built in CLANG64 terminal
- 32-bit when built in CLANG32 terminal
Notes
- Always use the correct terminal for each step:
- Main MSYS2 terminal for initial setup and toolchain installation
- CLANG64/32 terminals for dependency installation and building
- The choice between 32-bit and 64-bit should be consistent throughout the process
- Most modern Windows systems should use 64-bit builds. Only use 32-bit if you need compatibility with older systems
- The compiled executable will be statically linked, including all necessary libraries.
- (This just means it will create a single
.exe
file instead of having separate.dll
files that must be stored alongside the.exe
)
- (This just means it will create a single
- If you encounter package-related issues:
- First try updating packages in the main MSYS2 terminal:
pacman -Syu
- Then update in your specific CLANG terminal:
pacman -Syu
- First try updating packages in the main MSYS2 terminal:
- You can verify the architecture of your built executable using:
file jpeg2png.exe