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

SDL/SDL.h: No such file or directory #578

Closed
Peternj42 opened this issue Sep 19, 2023 · 2 comments
Closed

SDL/SDL.h: No such file or directory #578

Peternj42 opened this issue Sep 19, 2023 · 2 comments

Comments

@Peternj42
Copy link

Peternj42 commented Sep 19, 2023

Go version: 1.21.1
Go-SDL2 version: 0.4.35
SDL2 version: 2.28.3
OS: Windows
Architecture: amd64

I installed go-sdl2, mingw and sdl2 for windows per the instructions and added them to PATH. In the editor everything appears to be working - the import paths are resolved and I'm able to get code completion for the go-sdl2 package, but when I build, I get this error:

In file included from C:\Users\peter\go\pkg\mod\github.com\veandco\go-sdl2@v0.4.35\sdl\audio.go:4:
./sdl_wrapper.h:2:11: fatal error: SDL2/SDL.h: No such file or directory
2 | #include <SDL2/SDL.h>
| ^~~~~~~~~~~~

I've reviewed the other issues that have gotten similar errors but have not been able to get their solutions to work. I found that by changing the include in audio.go to the absolute path resolves the error for that file:

#include "C:/Program Files (x86)/mingw64/x86_64-w64-mingw32/include/SDL2/SDL.h"

but it looks like I would have to do this to every #include statement in every .go file, so I think I must be doing something wrong. I've double checked the installed files and the path variables but can't figure out why the compiler can't find the .h files. Any help would be appreciated. Thanks!

EDIT: I was able to compile successfully with:

go build -tags static -ldflags "-s -w"

but a standard go build gives the above error

@veeableful
Copy link
Contributor

Hi @Peternj42, could you show what's in your PATH?

@Peternj42
Copy link
Author

Fixed! Taking a closer look at my Path I found a different version of gcc in another directory higher up in PATH. Go must have found that one first, then the relative paths to SDL wouldn't work. Removed the other gcc from PATH and it works now. Thanks!

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

2 participants