Extract the SDL2 development package and copy the x86_64-w64-mingw folder inside recursively to the system's MinGW x86_64-w64-mingw32 folder.
Install MinGW through Homebrew via brew install mingw-w64.Now you should be able to run the program using Wine or Windows!.Before running the program, you need to put SDL2.dll from the SDL2 runtime package (For others like SDL_image, SDL_mixer, etc., look for them here) for Windows in the same folder as your executable.In this example, it should produce a main.exe executable file. You can change some of the parameters if you'd like to. Now you can start cross-compiling your Go program by running env CGO_ENABLED="1" CC="/usr/bin/x86_64-w64-mingw32-gcc" GOOS="windows" CGO_LDFLAGS="-lmingw32 -lSDL2" CGO_CFLAGS="-D_REENTRANT" go build -x main.go.You may also do the same for the i686-w64-mingw32 folder. Extract the SDL2 development package and copy the x86_64-w64-mingw32 folder inside recursively to the system's MinGW x86_64-w64-mingw32 folder.
You can also cross-compile to another OS. To build statically, run:ĬGO_ENABLED=1 CC=gcc GOOS=linux GOARCH=amd64 go build -tags static -ldflags "-s -w" Since v0.3.0, it is possible to build statically against included libraries in.
With versioning system coming to Go soon, we'll make use of semantic versioning to ensure stability in the future. Import "/veandco/go-sdl2/sdl" func main() ĭue to go-sdl2 being under active development, a lot of breaking changes are going to happen during v0.x.