Skip to content
This repository was archived by the owner on Aug 10, 2021. It is now read-only.

mingw: obsolete crt #1734

Closed
msink opened this issue Jun 27, 2018 · 4 comments
Closed

mingw: obsolete crt #1734

msink opened this issue Jun 27, 2018 · 4 comments
Assignees

Comments

@msink
Copy link
Contributor

msink commented Jun 27, 2018

Trying to statically link SDL in Tetris sample:

--- a/samples/tetris/build.gradle
+++ b/samples/tetris/build.gradle
@@ -51,7 +51,7 @@ konanArtifacts {
         }
 
         target 'mingw', {
-            linkerOpts "$resFile -L${System.getenv("MINGW64_DIR")?:"c:/msys64/mingw64"}/lib -lSDL2 -mwindows"
+            linkerOpts "$resFile -L${System.getenv("MINGW64_DIR")?:"c:/msys64/mingw64"}/lib -static -lSDL2  -limm32 -lole32 -loleaut32 -lversion -lwinmm -mwindows"
             dependsOn 'windowsResources'
             inputs.file resFile
         }

get this error:

> Task :tetris:compileKonanTetrisMingw_x64
c:\msys64\mingw64/lib\libSDL2.a(SDL_assert.o):(.text+0x2e4): undefined reference to `__imp___acrt_iob_func'
c:\msys64\mingw64/lib\libSDL2.a(SDL_log.o):(.text+0xcb): undefined reference to `__imp___acrt_iob_func'

Seems like it's same as rust-lang/rust#47048 - msys2 now uses mingw-w64-x86_64-crt-git-6.0.0, but Kotlin uses bundled with clang-5.0 mingw-w64-x86_64-crt-git-5.0.0.

@msink
Copy link
Contributor Author

msink commented Jul 19, 2018

Well, on llvm6 branch crt issue fixed, but now instead of single SDL2.dll it requires 3 libs: libgcc_s_seh-1.dll libstdc++-6.dll libwinpthread-1.dll

@sbogolepov
Copy link
Contributor

sbogolepov commented Jul 19, 2018

Well, it's still marked as WIP :)

@msink
Copy link
Contributor Author

msink commented Jul 19, 2018

Found it - -Wl,-Bstatic -lstdc++
So final path to fully static tetris for mingw on llvm6 branch:

@@ -49,11 +49,11 @@ konanArtifacts {
         target 'raspberrypi', {
             linkerOpts '-lSDL2'
         }
 
         target 'mingw', {
-            linkerOpts "$resFile -L${System.getenv("MINGW64_DIR")?:"c:/msys64/mingw64"}/lib -lSDL2 -mwindows"
+            linkerOpts "$resFile -L${System.getenv("MINGW64_DIR")?:"c:/msys64/mingw64"}/lib -Wl,-Bstatic -lstdc++ -static -lSDL2 -limm32 -lole32 -loleaut32 -lversion -lwinmm -mwindows"
             dependsOn 'windowsResources'
             inputs.file resFile
         }
     }
 }

@sbogolepov sbogolepov self-assigned this Aug 13, 2018
@sbogolepov
Copy link
Contributor

Fixed in master.

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants