Statically link MinGW builds to eliminate DLL dependencies#6
Statically link MinGW builds to eliminate DLL dependencies#6forloopcodes merged 2 commits intomainfrom
Conversation
Co-authored-by: ForLoopCodes <89027512+ForLoopCodes@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the MinGW (non-MSVC) build configuration to produce a fully statically linked Windows executable, eliminating runtime DLL dependencies like libwinpthread-1.dll for release artifacts.
Changes:
- Add
-staticto the MinGW linker flags forlegacy-notepadbuilds.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| target_link_options(legacy-notepad PRIVATE -mwindows -municode -static) | ||
| target_link_libraries(legacy-notepad PRIVATE -static-libgcc -static-libstdc++) |
There was a problem hiding this comment.
-mwindows is already added via CMAKE_EXE_LINKER_FLAGS in the non-MSVC branch (line 13) and -municode is already added via add_compile_options (line 12). With the new -static flag, this block now duplicates flags and also mixes linker flags between target_link_options (line 46) and target_link_libraries (line 47). Consider keeping only -static in target_link_options and moving -static-libgcc/-static-libstdc++ into target_link_options as well (leaving target_link_libraries for actual libraries) to avoid confusing/fragile flag handling.
| target_link_options(legacy-notepad PRIVATE -mwindows -municode -static) | |
| target_link_libraries(legacy-notepad PRIVATE -static-libgcc -static-libstdc++) | |
| target_link_options(legacy-notepad PRIVATE -static -static-libgcc -static-libstdc++) |
Releases built with MinGW depend on
libwinpthread-1.dlland other runtime DLLs, requiring users to have MinGW installed.Changes
-staticflag to MinGW linker options in CMakeLists.txtThe existing
-static-libgcc -static-libstdc++flags only covered GCC/C++ runtimes. The-staticflag ensures complete static linking including winpthread.Result: Standalone exe with no MinGW dependencies. MSVC builds unchanged.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.