andlabs / ui

Platform-native GUI library for Go.
Other
8.34k stars 647 forks source link

Linker error when compiling to Windows when importing github.com/andlabs/ui #326

Closed jclc closed 6 years ago

jclc commented 6 years ago

I'm importing this package alongside https://github.com/veandco/go-sdl2 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?

jclc commented 6 years ago

Meant to post this issue on go-sdl2. Sorry.

andlabs commented 6 years ago

For what it's worth, those specific linker errors have nothing to do with C++; they have to do with missing -loleaut32, -limm32, and -lversion in the linker flags.

jclc commented 6 years ago

Well what do you know, adding those + -lole32 fixed it, thanks! It is odd that this only occurs when importing both ui and go-sdl2/sdl, individually they build just fine.