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

What am I doing wrong? #522

Open Keyn1 opened 2 years ago

Keyn1 commented 2 years ago

If I compile a program with "github.com/veandco/go-sdl2/sdl "then everything is ok. The program is compiled. If I insert "github.com/veandco/go-sdl2/ttf " then I get an error

C:\GoPrg\sdl2_start>go build main.go # github.com/veandco/go-sdl2/ttf In file included from C:\Users\Keyn\go\pkg\mod\github.com\veandco\go-sdl2@v0.4.21\ttf\sdl_ttf.go:6: ./sdl_ttf_wrapper.h:2:18: fatal error: SDL2/SDL_ttf.h: No such file or directory 2 | #include <SDL2/SDL_ttf.h> | ^~~~ compilation terminated.

the file exists C:\Users\Keyn\go\pkg\mod\github.com\veandco\go-sdl2@v0.4.21.go-sdl2-libs\include\SDL2\SDL_ttf.h

How to solve the problem?

veeableful commented 2 years ago

Hi @Keyn1, I think that is because SDL2_ttf is not installed in the Windows environment. You can download the runtime library here and the header file from the source code here. They can be put in the same location as the SDL2 that you have installed.

Alternatively, you could try running the static compilation build that has been tested to work in Linux. It would use our included, pre-compiled SDL2 libraries using go build -tags static -ldflags="-s -w" on Windows. I tested running it using Git Bash and it seems to work.