Skip to content
Petr Vanek edited this page Oct 30, 2018 · 1 revision

Use MSYS2 to Build Windows Binaries

MSYS2 is a software distro and building platform for Windows

Install MSYS2

http://www.msys2.org/

MSYS2 comes with 3 sort-of independent shells:

  • MSYS2 shell - a shell for regular work
  • MINGW32 shell - a shell for cross compilation to get native Windows binaries. For 32bit Windows
  • MINGW64 shell - a shell for cross compilation to get native Windows binaries. For 64bit Windows

Packages in MSYS2 are also created for 3 shells:

  • standard packages with normal names -> MSYS2 shell
  • prefixed with mingw-w64-i686 -> MINGW32 shell
  • prefixed with mingw-w64-x86_64 -> MINGW64 shell

If you open a MINGWxx shell, your env will be configured to use environment only with mingw* prefixed packages.

In the following text I'm using MSYS2 for Windows 64 bit (but still it can create 32b binaries). If you have 32 bit Windows you should download MSYS2 for 32bit architecture and update package names below.

Install Environment

Use MSYS2 shell, install packages:

pacman -Syu
pacman -Su
pacman -S git
pacman -S make bison flex pkg-config
pacman -S pcre-devel

packages for cross compilation (used under MINGW env later)

The prefixes are:

  • MINGW env for 32bit: mingw-w64-i686
  • MINGW env for 64bit: mingw-w64-x86_64

Target: Windows 64bit

pacman -S mingw-w64-x86_64-cmake
pacman -S mingw-w64-x86_64-gcc
pacman -S mingw-w64-x86_64-doxygen
pacman -S mingw-w64-x86_64-graphviz
pacman -S mingw-w64-x86_64-libiconv
pacman -S mingw-w64-x86_64-openssl
pacman -S mingw-w64-x86_64-mpfr
pacman -S mingw-w64-x86_64-pcre
pacman -S mingw-w64-x86_64-dlfcn

Target: Windows 32bit

pacman -S mingw-w64-i686-cmake
pacman -S mingw-w64-i686-gcc
pacman -S mingw-w64-i686-doxygen
pacman -S mingw-w64-i686-graphviz
pacman -S mingw-w64-i686-libiconv
pacman -S mingw-w64-i686-openssl
pacman -S mingw-w64-i686-mpfr
pacman -S mingw-w64-i686-pcre
pacman -S mingw-w64-i686-dlfcn

Building for Windows

Start the MINGWxx environment

git clone ...
cd qore
mkdir build
cd build
# for example:
cmake -G "Unix Makefiles" .. -DCMAKE_INSTALL_PREFIX=~/release
make
make install

Deployment

Bundle all DLLs into the target lib. Call from CMAKE_INSTALL_PREFIX/bin

cp `ldd qore.exe |grep mingw64|cut -d " " -f 3` .

Building of a Module

export PATH=$PATH=<the value used in Qore's CMAKE_INSTALL_PREFIX + /bin>
git clone ..
cd <module-dir>
<cmake or autotools>
make
make install