go-sdl2: Linker error when compiling to Windows when importing github.com/andlabs/ui

I’m importing this package alongside github.com/andlabs/ui and I get this error when cross-compiling to Windows using mingw:

/usr/lib/go/pkg/tool/linux_amd64/link: running x86_64-w64-mingw32-g++ failed: exit status 1
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windows.o):(.text+0x17f): undefined reference to `__imp_CoInitializeEx'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0xf6): undefined reference to `ImmGetIMEFileNameA'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x144): undefined reference to `ImmGetContext'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x167): undefined reference to `ImmReleaseContext'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x1d4): undefined reference to `ImmGetCompositionStringW'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x1ec): undefined reference to `ImmGetCompositionStringW'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x3ff): undefined reference to `ImmGetIMEFileNameA'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x569): undefined reference to `GetFileVersionInfoSizeA'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x595): undefined reference to `GetFileVersionInfoA'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x5bf): undefined reference to `VerQueryValueA'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x85c): undefined reference to `__imp_SysFreeString'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x9ee): undefined reference to `ImmGetContext'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0xa0c): undefined reference to `ImmNotifyIME'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0xa29): undefined reference to `ImmNotifyIME'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0xa35): undefined reference to `ImmReleaseContext'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0xa83): undefined reference to `ImmSetCompositionStringW'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0xb13): undefined reference to `ImmAssociateContext'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0xc2d): undefined reference to `ImmGetContext'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0xc3c): undefined reference to `ImmReleaseContext'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x12bd): undefined reference to `ImmAssociateContext'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x14f5): undefined reference to `ImmAssociateContext'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x158c): undefined reference to `ImmGetContext'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x15bd): undefined reference to `ImmSetCompositionWindow'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x15c9): undefined reference to `ImmReleaseContext'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x16a1): undefined reference to `ImmGetContext'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x16ed): undefined reference to `ImmReleaseContext'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x17de): undefined reference to `ImmGetContext'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x17ff): undefined reference to `ImmGetCandidateListW'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x1814): undefined reference to `ImmReleaseContext'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x198b): undefined reference to `ImmGetContext'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x1a21): undefined reference to `ImmReleaseContext'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x1a6d): undefined reference to `ImmGetCandidateListW'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x1dc6): undefined reference to `__imp_SysFreeString'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_windowskeyboard.o):(.text+0x1ebb): undefined reference to `__imp_SysFreeString'
/usr/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libSDL2.a(SDL_wasapi.o):(.text+0x355): undefined reference to `__imp_PropVariantClear'
collect2: virhe: ld:n paluuarvo oli 1

The package ui uses C++, could this be confusing the Go linker into using C++ linkage for SDL2?

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 19 (15 by maintainers)

Most upvoted comments

Hi @jclc, I’ll have a look at this as well during the weekend. I’ll keep you posted!