Skip to content

Commit

Permalink
Fix static linking using MinGW-w64
Browse files Browse the repository at this point in the history
  • Loading branch information
HertzDevil committed Nov 6, 2024
1 parent 650bb6d commit 211469d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
12 changes: 5 additions & 7 deletions src/crystal/system/win32/wmain.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ require "c/stringapiset"
require "c/winnls"
require "c/stdlib"

{% begin %}
# we have both `main` and `wmain`, so we must choose an unambiguous entry point
# we have both `main` and `wmain`, so we must choose an unambiguous entry point
{% if flag?(:msvc) %}
@[Link({{ flag?(:static) ? "libcmt" : "msvcrt" }})]
{% if flag?(:msvc) %}
@[Link(ldflags: "/ENTRY:wmainCRTStartup")]
{% elsif flag?(:gnu) && !flag?(:interpreted) %}
@[Link(ldflags: "-municode")]
{% end %}
@[Link(ldflags: "/ENTRY:wmainCRTStartup")]
{% elsif flag?(:gnu) && !flag?(:interpreted) %}
@[Link(ldflags: "-municode")]
{% end %}
lib LibCrystalMain
end
Expand Down
2 changes: 1 addition & 1 deletion src/empty.cr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "primitives"

{% if flag?(:win32) %}
{% if flag?(:msvc) %}
@[Link({{ flag?(:static) ? "libcmt" : "msvcrt" }})] # For `mainCRTStartup`
{% end %}
lib LibCrystalMain
Expand Down
4 changes: 3 additions & 1 deletion src/lib_c.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% if flag?(:win32) %}
{% if flag?(:msvc) %}
@[Link({{ flag?(:static) ? "libucrt" : "ucrt" }})]
{% elsif flag?(:win32) && flag?(:gnu) %}
@[Link(ldflags: "-mcrtdll=ucrt")]
{% end %}
lib LibC
alias Char = UInt8
Expand Down

0 comments on commit 211469d

Please sign in to comment.