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

can't install sdl2 in win10 #472

Closed wenchaomartin closed 3 years ago

wenchaomartin commented 3 years ago

win10 professional

D:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64

i am newer in go , i install the sdl from descprition
flow the step 1,2 but get error when type the command go get -v

github.com/veandco/go-sdl2/sdl image

veeableful commented 3 years ago

Hi @wenchaomartin, could you post the full output of the go get -v? Thanks!

wenchaomartin commented 3 years ago

$ go get -v github.com/veandco/go-sdl2/sdl

output

github.com/veandco/go-sdl2/sdl src\github.com\veandco\go-sdl2\sdl\audio.go:6:26: error: missing binary operator before token "("

if !(SDL_VERSION_ATLEAST(2,0,4))

                      ^

src\github.com\veandco\go-sdl2\sdl\audio.go:25:26: error: missing binary operator before token "("

if !(SDL_VERSION_ATLEAST(2,0,5))

                      ^

src\github.com\veandco\go-sdl2\sdl\audio.go:37:26: error: missing binary operator before token "("

if !(SDL_VERSION_ATLEAST(2,0,7))

veeableful commented 3 years ago

Hi @wenchaomartin, I could not replicate the problems. Could you print the output of go version, uname -a, and go env as well? I wonder if it's because of old compiler or some mismatch in configurations. Thanks again!

wenchaomartin commented 3 years ago

hi @veeableful
C:\Users\Administrator>go version go version go1.14.1 windows/amd64

$ uname -a MINGW64_NT-10.0-18362 DESKTOP-T90CO9O 3.0.7-338.x86_64 2019-07-03 15:16 UTC x86_64 Msys

C:\Users\Administrator>go env set GO111MODULE= set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\Administrator\AppData\Local\go-build set GOENV=C:\Users\Administrator\AppData\Roaming\go\env set GOEXE=.exe set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOINSECURE= set GONOPROXY= set GONOSUMDB= set GOOS=windows set GOPATH=D:\go set GOPRIVATE= set GOPROXY=https://proxy.golang.org,direct set GOROOT=D:\program\Go set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLDIR=D:\program\Go\pkg\tool\windows_amd64 set GCCGO=gccgo set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD= set CGO_CFLAGS=-g -O2 set CGO_CPPFLAGS= set CGO_CXXFLAGS=-g -O2 set CGO_FFLAGS=-g -O2 set CGO_LDFLAGS=-g -O2 set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\ADMINI~1\AppData\Local\Temp\go-build769517126=/tmp/go-build -gno-record-gcc-switches

veeableful commented 3 years ago

Hi @wenchaomartin, how did you install the native SDL2 libraries? Did you do any modifications at all? From what I see, it looks like the compiler could not find the macro SDL_VERSION_ATLEAST and that might be caused by some missteps during the installation of native SDL2 libraries.

Perhaps you could try a fresh install of the native SDL2 libraries and see if it solves the problem? If possible, perhaps you could even do a fresh install of MinGW before that just to be sure everything is clean.

wenchaomartin commented 3 years ago

hi @veeableful i switch another computer win10 professional, i install all stuff again , but found following

$ go get -v github.com/veandco/go-sdl2/{sdl,img,mix,ttf} github.com/veandco/go-sdl2/ttf github.com/veandco/go-sdl2/img github.com/veandco/go-sdl2/mix github.com/veandco/go-sdl2/ttf

In file included from go\src\github.com\veandco\go-sdl2\ttf\sdl_ttf.go:5: ./sdl_ttf_wrapper.h:2:11: fatal error: SDL2/SDL_ttf.h: No such file or directory

include <SDL2/SDL_ttf.h>

       ^~~~~~~~~~~~~~~~

compilation terminated. github.com/veandco/go-sdl2/img In file included from go\src\github.com\veandco\go-sdl2\img\sdl_image.go:5: ./sdl_image_wrapper.h:2:11: fatal error: SDL2/SDL_image.h: No such file or directory

include <SDL2/SDL_image.h>

       ^~~~~~~~~~~~~~~~~~

$ go env set GO111MODULE= set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\Administrator\AppData\Local\go-build set GOENV=C:\Users\Administrator\AppData\Roaming\go\env set GOEXE=.exe set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOINSECURE= set GOMODCACHE=C:\Users\Administrator\go\pkg\mod set GONOPROXY= set GONOSUMDB= set GOOS=windows set GOPATH=C:\Users\Administrator\go set GOPRIVATE= set GOPROXY=https://proxy.golang.org,direct set GOROOT=c:\go set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLDIR=c:\go\pkg\tool\windows_amd64 set GCCGO=gccgo set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD= set CGO_CFLAGS=-g -O2 set CGO_CPPFLAGS= set CGO_CXXFLAGS=-g -O2 set CGO_FFLAGS=-g -O2 set CGO_LDFLAGS=-g -O2 set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\ADMINI~1\AppData\Local\Temp\go-build812005350=/tmp/go-build -gno-record-gcc-switches

$ go version go version go1.15 windows/amd64

$ uname -a MINGW64_NT-10.0-17763 PC-202002081437 3.1.6-340.x86_64 2020-07-09 14:33 UTC x86_64 Msys

veeableful commented 3 years ago

Hi @wenchaomartin, it looks like you haven't installed SDL2_ttf and SDL2_image. You should be able to install them the same way as SDL2.

wenchaomartin commented 3 years ago

@veeableful thanks a lot , i test sample code from read.me, popup a windows which contains red rectangle .