veandco / go-sdl2

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

Not compatible with Go 1.21.0 #577

Open dsoechting opened 10 months ago

dsoechting commented 10 months ago

Go version: 1.21.0 Go-SDL2 version: v0.4.35 SDL2 version: 2.0.20 OS: Windows 10 (19045.3324) -> Ubuntu 22.04.2 LTS through WSL2 Architecture: x86-64 (Ryzen 3700x CPU)

When I installed the Go module, none of the go-sdl2 functions were accessible from my application code besides some Btoi function in a file called helper.go. I could see all of the source code when looking at the module from my file system, but could not use most it.

I resolved my issue by downgrading to Go 1.20.7. Perhaps a note in the documentation could be made.

veeableful commented 10 months ago

Hi @dsoechting, would you be able to provide a minimal example project that reproduces the issue? I was able to use Go 1.21 on my Linux and macOS with go-sdl2 v0.4.35.

gen2brain commented 10 months ago

@dsoechting Looks like you have CGO_ENABLED=0 globally. Check with go env.

Yagisanatode commented 10 months ago

This also occurred with me.

go version go1.21.0 windows/amd64 SDL2 version: 2.0.20

As @gen2brain mentioned the env setting for this is CGO_ENABLED=0

I'm a little lost on how to change this setting being a very fresh noob to Go (I don't think I am using the right keywords to search for it).

Any suggestions would be appreciated.

veeableful commented 10 months ago

Hi @Yagisanatode, you could try putting it before the command. For example, CGO_ENABLED=1 go build.

Yagisanatode commented 9 months ago

@veeableful thanks for the guidance. My issue ended up being a combination on failing to add the g++.exe file and not adding the sdl2 dll to the module path.

ramizpolic commented 9 months ago

Would love to contribute to this if this is still relevant

gen2brain commented 9 months ago

@ramizpolic I don't think there is much to contribute here. Perhaps adding some notes for users in documentation, how it looks when there is no C compiler, how it looks when CGO is disabled etc. Something like that maybe,