-
Notifications
You must be signed in to change notification settings - Fork 0
Windows
Windows is a comparatively easy platform to distribute binaries for. There are almost no binary compatibility concerns.
An easy way to reduce platform-specifics in the build process is to use MinGW-w64 (GCC toolchain for Windows). You can install this and many other Unix-y tools and libraries with MSYS2.
Plain MinGW GCC will link against the Windows C API called msvcrt (Microsoft Visual C runtime). If you need to, you can also install libraries and compilers that link with Cygwin (POSIX compatibility C libraries) from the msys2 package repo instead of mingw64. (Remember to ship the Cygwin DLL if you do.)
(Note: both MinGW-w64 and Cygwin projects have their own installers, but IME it's far easier to manage them via MSYS2.)
For C programs (or similar), icons get compiled to object files by the "resource compiler" which are then linked with the exe.
Create a .ico, then write a text file with extension .rc with contents:
id ICON "path/to/icon.ico"
MinGW contains the resource compiler windres, which is used like windres icon.rc icon.o
. Then, link icon.o with the rest of your object files.
You could write a Make rules like so:
%.rc: %.ico
echo 'id ICON "$<"' > $@
%.o: %.rc
windres $< $@
Windows executables always look for DLLs in the current directory, always have their full path as argv[0], and shortcuts by default run with the cwd of the executable. This makes it really easy to ship self-contained folders. Just copy all the required DLLs next to the exe (straight from MSYS2 /bin
will work), put them in a folder and zip.
TODO installers? single-file exes?