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