Skip to content

Statically link MinGW builds to eliminate DLL dependencies#6

Merged
forloopcodes merged 2 commits intomainfrom
copilot/release-statically-linked-exe
Jan 30, 2026
Merged

Statically link MinGW builds to eliminate DLL dependencies#6
forloopcodes merged 2 commits intomainfrom
copilot/release-statically-linked-exe

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 30, 2026

Releases built with MinGW depend on libwinpthread-1.dll and other runtime DLLs, requiring users to have MinGW installed.

Changes

  • Added -static flag to MinGW linker options in CMakeLists.txt

The existing -static-libgcc -static-libstdc++ flags only covered GCC/C++ runtimes. The -static flag ensures complete static linking including winpthread.

if(NOT MSVC)
    target_link_options(legacy-notepad PRIVATE -mwindows -municode -static)
    target_link_libraries(legacy-notepad PRIVATE -static-libgcc -static-libstdc++)
    # ...
endif()

Result: Standalone exe with no MinGW dependencies. MSVC builds unchanged.

Original prompt

This section details on the original issue you should resolve

<issue_title>The exe download from the release does not work without MinGW installed</issue_title>
<issue_description>The exe depends on some MinGW dll. Please release a statically linked exe.</issue_description>

Comments on the Issue (you are @copilot in this section)

@forloopcodes will fix! can you try out the old version though? does it work

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: ForLoopCodes <89027512+ForLoopCodes@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix exe download issue by releasing statically linked exe Statically link MinGW builds to eliminate DLL dependencies Jan 30, 2026
Copilot AI requested a review from forloopcodes January 30, 2026 13:08
Copy link
Copy Markdown
Owner

@forloopcodes forloopcodes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@forloopcodes forloopcodes marked this pull request as ready for review January 30, 2026 13:10
Copilot AI review requested due to automatic review settings January 30, 2026 13:10
@forloopcodes forloopcodes merged commit 657d2a2 into main Jan 30, 2026
3 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 -static to the MinGW linker flags for legacy-notepad builds.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CMakeLists.txt
Comment on lines +46 to 47
target_link_options(legacy-notepad PRIVATE -mwindows -municode -static)
target_link_libraries(legacy-notepad PRIVATE -static-libgcc -static-libstdc++)
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-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.

Suggested change
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++)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The exe download from the release does not work without MinGW installed

3 participants