Andrew Moa Blog Site

Method for Static Compile with the MSYS2 Toolchain

The advantage of static compilation is that you don’t need to include a bunch of dynamic link libraries when publishing. In theory, the Msys2 toolchain supports static compilation, but in practice, even if you directly add the -static flag, the generated executable still reports missing dynamic link libraries at runtime, especially the three libraries required by the Mingw toolchain: libwinpthread-1.dll, libstdc++-6.dll, and libgcc_s_seh-1.dll. For the clang compiler, the runtime dependency becomes libc++.dll. This article explores a simple method to facilitate static link compilation management for different compilers.
4 minutes to read
Andrew Moa

Handling Event Callback Functions with Lambda Expressions

C++11 began supporting lambda expressions. Besides being used as anonymous functions, lambda expressions can also access variables in the surrounding environment through a capture list. In UI programming, using lambda expressions instead of traditional function pointers for handling callback functions can not only simplify the code and improve readability but also reduce parameter passing and increase flexibility. Below, we attempt to implement related operations for commonly used C++ UI libraries.
19 minutes to read
Andrew Moa

Exploring implementation methods for separating interface and methods

Separating the program’s UI from the implementation code of its methods is very helpful for improving development efficiency and code readability. Mainstream UI libraries such as Qt, wxWidgets, and GTK each have their own implementation approaches, which will be demonstrated below.

1. wxWidgets project based on XRC

1.1 Write XRC file

wxWidgets supports defining the UI through XML format and saving it as an XRC file. Using XRC files allows for separating the interface from the code, but the downside is that the released program will be slightly larger compared to the non-XRC version.

14 minutes to read
Andrew Moa