go-sdl2 icon indicating copy to clipboard operation
go-sdl2 copied to clipboard

Failed to cross-compile to Windows i386: GetDoubleClickTime

Open 20kdc opened this issue 5 years ago • 3 comments

On an Ubuntu 19.10 (Eoan Ermine) system, the following command: CGO_ENABLED=1 CC=i686-w64-mingw32-gcc GOOS=windows GOARCH=386 go build -v -tags static -ldflags "-s -w" fails to build https://github.com/20kdc/CCUpdaterUI (Please be noted: If you wish to test this specific application, it expects my fork of CCUpdaterCLI) with:

/usr/bin/i686-w64-mingw32-ld: ../../veandco/go-sdl2/sdl/../.go-sdl2-libs/libSDL2_windows_386.a(SDL_mouse.o):(.text+0xa1): undefined reference to `GetDoubleClickTime'

Note: This issue mostly exists to document the workaround, which is:

Overwriting the .go-sdl2-libs files with the relevant MinGW static libraries (not the .dll-postfixed ones) from https://www.libsdl.org/download-2.0.php works.

Specifically: If an issue occurred with GetDoubleClickTime:

  • Get the MinGW devlibs from https://www.libsdl.org/download-2.0.php
  • Overwrite libSDL2_windows_386.a with 32-bit libSDL2.a
  • Overwrite libSDL2main_windows_386.a with 32-bit libSDL2main.a

20kdc avatar Dec 06 '19 18:12 20kdc

Hi @20kdc, thanks for the workaround. It does work! I tested it by compiling the library (e.g. cd $GOPATH/src/github.com/veandco/go-sdl2/sdl then run CGO_ENABLED=1 CC=i686-w64-mingw32-gcc GOOS=windows GOARCH=386 go install -v -tags static -ldflags "-s -w".

Do you think we could simply update the Windows 32-bit .a files with the ones from the website, @gen2brain? Or did you compile the static libraries yourself with a special way?

veeableful avatar Dec 07 '19 16:12 veeableful

Hi @veeableful , libs are compiled with minimal dependencies (i.e. without smpeg, flac, mikmod, modplug etc.) and made to work by default with libmpg123. All libs are cross-compiled on Linux (except for darwin but I can now also cross-compile for darwin on Linux).

I don't have any automatic procedure for the build, just some notes, will try to compile and update everything again, not sure when will I find time to do that though.

btw. that GetDoubleClickTime is strange, that is in user32 and it does link that lib, maybe order is important for that one.

gen2brain avatar Dec 07 '19 18:12 gen2brain

I see, thank you @gen2brain. Let me know if I can help with the build. I certainly have some time to spare :grin:

veeableful avatar Dec 08 '19 04:12 veeableful