veandco / go-sdl2

SDL2 binding for Go
https://godoc.org/github.com/veandco/go-sdl2
BSD 3-Clause "New" or "Revised" License
2.2k stars 218 forks source link

ttf: added MacOS include for sdl_ttf_wrapper.h #373

Closed sk4r closed 5 years ago

sk4r commented 5 years ago

On MacOS I am getting

./sdl_ttf_wrapper.h:5:11: fatal error: 'SDL_ttf.h' file not found
        #include <SDL_ttf.h>
                 ^~~~~~~~~~~

I have sdl2_ttf installed through brew, and that header is symlinked to /usr/local/include/SDL2/SDL_ttf.h.

This PR adds a directive to account for that.

sk4r commented 5 years ago

It may be worth adding the same ifdef to other wrappers. I am not using all of them, but this is the only failure I saw so far.

veeableful commented 5 years ago

Hmm strange, it works without the modification for me. What's the output of pkg-config --cflags sdl2_ttf? Does SDL_ttf.h exist in that directory?

sk4r commented 5 years ago
$ pkg-config --cflags sdl2_ttf
Package sdl2_ttf was not found in the pkg-config search path.
Perhaps you should add the directory containing `sdl2_ttf.pc'
to the PKG_CONFIG_PATH environment variable
No package 'sdl2_ttf' found

After adding export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/usr/local/Cellar/sdl2_ttf/2.0.14/lib/pkgconfig" it says

$ pkg-config --cflags sdl2_ttf
-D_THREAD_SAFE -I/usr/local/include/SDL2 -I/opt/local/include/SDL2

SDL_ttf.h exists in /usr/local/include/SDL2 but not in /opt/local/include/SDL2

Did you also manually set that variable or am I missing some automated step?

However, somehow I'm still getting

In file included from ../../go/pkg/mod/github.com/veandco/go-sdl2@v0.3.0/ttf/sdl_ttf.go:5:
./sdl_ttf_wrapper.h:5:11: fatal error: 'SDL_ttf.h' file not found
        #include <SDL_ttf.h>
                 ^~~~~~~~~~~
1 error generated.

Maybe something else is missing?

veeableful commented 5 years ago

Hmm my pkg-config --cflags sdl2_ttf output is: -D_THREAD_SAFE -I/usr/local/include/SDL2

I wonder where the /opt one comes from.

Perhaps cleaning the build directory will help? Or run go get -a github.com/veandco/go-sdl2/ttf. I'm wondering if the old pkg-config settings are still in there somewhere.

sk4r commented 5 years ago

I just installed sdl2_ttf using macports and the problem went away, something must be weird with homebrew. Which do you use/recommend?

sk4r commented 5 years ago

Anyway, if the current config works on a mac for you, this seems like a configuration issue, so I'm closing the PR. Thanks!

veeableful commented 5 years ago

I used Homebrew to install SDL2 and the rest. I'm not a heavy macOS user but Homebrew seems like the standard package manager 😛