For the last few years I have been working on getting gedit builds for Windows and it has never been as easy as now. In this post I will explain the steps you have to do to easily build your application on Windows.
- Install the latest version of msys2. You can get it from http://msys2.github.io/. Ensure to install it on a short directory path, i.e the default c:\msys64 should be fine. Highlight that this is msys2, which compared with the previous msys system this one is fast and well maintained.
- Open the msys2_shell.bat that you can find in c:\msys64.
- Update it by running: pacman -Syu. This will probably update msys2 so you will have to relaunch again the shell.
- Install the toolchain, in my case I installed the x86_64 but you can install i686 or both. To do so: pacman -S mingw-w64-x86_64-toolchain
- Create a PKGBUILD file as you would do for Arch Linux for the package you would like to build for windows. You can find the gedit one here. Or you can find more information on how to create this file on the Arch Linux wiki.
- Once you have the PKGBUILD file ready build it by running “makepkg-mingw -sL”. This will build your project and generate a package.
- Install this package with pacman -U file
- If that package your are trying to build is not already shipped by msys2 or if it is too old and you want to update it you can fork the MINGW-packages repository and add it to it and make a pull request.
- If the package reach upstream you will not need to build it anymore in order to use it but you can simply install it by doing: pacman -S mingw-w64-x86_64-package-name
- As an example installing gedit on Windows it is just a matter of installing msys2, update it and run “pacman -S mingw-w64-x86_64-gedit”
As you see installing and or building an application is not that difficult anymore, but as like for the case of gedit you might want to create an installer which will make easy to distribute your application. Since pacman allows you to create new roots, what I did is to create an installer based on pacman. The files can be found here. To explain a bit better how this works, here is what each file from that link mean:
- make-gedit-installer: is a bash script which installs the base msys2 system in a specific root, in this case /tmp/gedit, and then it installs gedit and all its dependencies. Since some of them are not needed as they are optional, it also takes care of removing them.
- make-gedit-installer.bat: it runs make-gedit-installer in 2 stages. The first one installs the basic system and the second stage installs gedit and its dependencies.
I hope this helps to get your application ported to Windows and if you have any questions you can contact the msys2 team on the #msys2 channel of the OFTC IRC. Of course if you have any doubt and you prefer to contact the gedit team we are like usual in the #gedit channel on the Gimpnet IRC.