veandco / go-sdl2

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

How to SDL on 64bit Windows Instructions Unclear #599

Open GustavBW opened 7 months ago

GustavBW commented 7 months ago

TLDR: I have gotten it to work now, but found the instructions unclear.

Go version: go1.21.0 windows/amd64

Go-SDL2 version: v2?

SDL2 version: SDL2-devel-2.30.2-mingw

OS: Windows 11

Architecture: 64bit

Hi, I've used Golang itself for some time but never any native bindings or dll's or anything like that. I might be overly pedantic in my understanding, but since I have no understanding in the first place, I had some issues following the setup instructions.

I've followed the instructions as described in the main readme here, and the first lapse in my understanding is the mention of a mingw64 folder. What I have is H:/msys64/mingw64, which is the default path when you install MinGW (aside from the drive that is) so I assumed that was what was meant.

The second lapse is step 3 mentioning putting some mingw-w64 binaries on the system path. I have no such folder, but there was a bin in msys64/mingw64/bin so I assumed it was that one.

And third and finally, the SDL2 github has no win64 release. At first this stumped me a lot because I didn't know that the SDL2-2.30.2-win32-x64 release would work (I thought win32 was officially out-dated and unsupported) so I went searching elsewhere and tried a bunch of different .dll's from arguably questionable sources.

Its not a lot, and someone with more experience with this would breeze through the instructions, but it could be nice if they were a little more explicit with the details.

Lundis commented 4 months ago

I gave up making official builds for windows in windows. instead I cross-compile statically on Ubuntu when I need a windows build that works on any machine:

    sudo apt-get install mingw-w64 g++-mingw-w64-x86-64

    CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=/usr/bin/x86_64-w64-mingw32-gcc go build -v -o game.exe -ldflags "-s -w" -tags osusergo,netgo,static