veandco / go-sdl2

SDL2 binding for Go
https://godoc.org/github.com/veandco/go-sdl2
BSD 3-Clause "New" or "Revised" License
2.18k stars 219 forks source link

Failed to cross-compile to Windows i386: GetDoubleClickTime #440

Open 20kdc opened 4 years ago

20kdc commented 4 years ago

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:

veeableful commented 4 years ago

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?

gen2brain commented 4 years ago

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.

veeableful commented 4 years ago

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