Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not Compiling on/for Windows #81

Open
SammCheese opened this issue Jul 2, 2022 · 3 comments
Open

Not Compiling on/for Windows #81

SammCheese opened this issue Jul 2, 2022 · 3 comments

Comments

@SammCheese
Copy link

SammCheese commented Jul 2, 2022

Both Cross compiling and Native Windows compiling seems to fail with the build script.

Branch: sdl-rework
Commit: latest
GO: go1.18.3

image

@9D-Tony
Copy link

9D-Tony commented Jul 26, 2022

I've found that printing out the "c.CombinedOutput()" line in the build script gives me this output:

# github.com/veandco/go-sdl2/sdl
In file included from ..\..\..\go\pkg\mod\github.com\veandco\[email protected]\sdl\audio.go:4:
./sdl_wrapper.h:2:11: fatal error: SDL2/SDL.h: No such file or directory
    2 |  #include <SDL2/SDL.h>
      |           ^~~~~~~~~~~~
compilation terminated.

<ERROR:  exit status 2>

Seems that one of the packages has a problem finding a SDL header file

@9D-Tony
Copy link

9D-Tony commented Jul 27, 2022

I got it to compile, unfortunatley I couldn't get it to run with SDL_gfx so for now I removed all references to gfx and did
go mod tidy.

I had to follow all the instruction on the Go SDL github, copying all the header files from the development SDL to my gcc folder. Example: going to https://github.com/libsdl-org/SDL/releases/tag/release-2.0.22 and downloading the SDL2-devel-2.0.22-mingw.zip. You do this for SDL, SDL_ttf and SDL_Image.

Since I am running on TDM-GCC mine was located in C:\TDM-GCC-64\x86_64-w64-mingw32
Then once you have removed all the references to SDL_gfx in the go files you can then build with go run ./build_script/main.go -b
NOTE removing sdl_gfx removes the frame limit so the application is going to draw as fast as it can

That is the only way i could get it to run on windows.

@eljamm
Copy link

eljamm commented Aug 17, 2022

After many failed attempts, I was finally able to compile it successfully on my voidlinux machine following the method @9D-Tony suggested, but i also found a way to keep SDL2_gfx and have frame limiting on.

To make the process more automatic i created this bash script, which in short just uses the static SDL2 libraries and header from go-sdl2 to compile to different targets and architectures from linux. I only used it to build linux and windows binaries, however, but it should be possible for mac too.

After downloading the script, you can remove the .sh extension but make sure it's executable with chmod +x ./masterbuilder. Then, either execute it inside the masterplan directory :

./masterbuilder -t windows -a amd64

or to keep things clean, point to it from another path :

./masterbuilder -t windows -a amd64 -s <path/to/masterplan> -o <path/to/output>

You can check out ./masterbuilder -h for more options.

Everything seemed to work fine during my brief tests, but i still haven't used the app for long enough to know for sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants