Mxgui qtsimulator on windows
On windows, an easy way to compile the mxgui qtsimulator is to use the MSYS2 toolchain, which provides a Unix-like environment for Windows development.
1. Install MSYS2
Download the MSYS 2 toolchain by downloading the prebuilt packages from the official site https://www.msys2.org. Then, follow the instructions on the website to install it.
Different toolchains in MSYS2
MSYS2 itself is just a unix-like environment running on Windows, like its predecessor Cygwin. Within this environment, MSYS2 provides multiple toolchains which target different architectures (x86_64 or ARM), use different main compilers (GCC or clang), or a different C runtime library (UCRT or mingw).
The recommended toolchain by the MSYS2 project at the current time is UCRT64, which targets x86_64, uses the GCC compiler and the UCRT runtime. UCRT is a modern C runtime for Windows, included with the OS since Windows 10, which removes the need to install the C runtime separately when distributing a program (as previously required).
Trivia: Before UCRT was introduced, the previous standard C runtime for MSYS2 was mingw. However, mingw was simply a wrapper augmenting an old Microsoft C runtime (msvcrt.dll) which for binary compatibility reasons is frozen in time since the release of Windows 95[1]. As a result, mingw always had serious compatibility problems and bugs.
MSYS2 adds menu items to the Start menu which launch bash shells with pre-configured paths (environments) for each one of the toolchains.
All of the following steps are intended to be executed using the shell opened by clicking on MSYS2 UCRT64.
2. Install build tools and prerequisites
Open the MSYS2 UCRT64 shell and perform an upgrade:
pacman -Syuu
Answer Yes to all prompts. If a "base system upgrade" was needed, at this point the shell will close. In this case, just open it up again.
Install the toolchain (including gcc and binutils):
Note: The mingw-w64-ucrt-x86_64 prefix in the package name identifies the toolchain and usually needs to be specified for all packages. Some packages that work the same way for all toolchains are exceptions to this rule.
pacman -S mingw-w64-ucrt-x86_64-toolchain
Install build automation tools (note that only CMake has a special version depending on the toolchain here):
pacman -S make difftools mingw-w64-ucrt-x86_64-cmake
Install the dependencies for the simulator and the code generation tools:
Note: When installing qt5 type enter to install all packages.
pacman -S mingw-w64-ucrt-x86_64-qt5 mingw-w64-ucrt-x86_64-libpng mingw-w64-ucrt-x86_64-zlib mingw-w64-ucrt-x86_64-boost
3. Build the code generation tools
Let us assume you already cloned mxgui's repository somewhere on your filesystem. If you haven't, do it now.
Tip: For using git on Windows, we recommend the official distribution (Git for Windows: https://git-scm.com/install/windows) and TortoiseGit for shell integration and GUI support (https://tortoisegit.org).
You can also install git inside MSYS2 by executing pacman -S git. However, this installs a different and separate version of Git, which exists simultaneously and independently from Git for Windows. By default you can't use Git for Windows inside a MSYS2 shell, or MSYS2-installed git in a Windows shell.
Change directory to _tools/code_generators:
cd ../../_tools/code_generators
Build the code generators with CMake.
mkdir build cd build cmake .. make
Note: If you want to make the compilation faster by using all the CPU cores in your machine, instead of just typing make type make -j4 where 4 stands for the number of CPU cores you have.
Of course you can do this any time you use make to compile something, not just for this one case.
If you don't know how many cores your CPU has, check in Task Manager.
4. Build the simulator
Now we only need to build the simulator. Change directory to the simulator's root:
cd ../../qtsimulator
Then build it like we did for the code generators:
mkdir build cd build cmake .. make
Now you should be able to run the simulator!
./qtsimulator.exe
Warning: If you double-click on the qtsimulator.exe executable in Windows Explorer, it probably won't work because of some missing DLLs. This is normal. The missing DLLs are located in C:\msys64\ucrt64\bin, a directory that the MSYS2 shell configuration adds to the PATH variable automatically, but is not normally included in PATH.
To make the simulator executable work when double-clicked, first check all the required DLLs by executing lld qtsimulator.exe in the MSYS2 shell, and then copy the DLLs located in C:\msys64\ucrt64\bin to the same directory as qtsimulator.exe.
However, unless you want to distribute the compiled simulator, it's much simpler to just always run it from inside an MSYS2 UCRT64 terminal window.

