Issue with SDL_ttf on Mac

I’m using cmake and a finder cmake file for sdlttf to build my makefile, as seen here.
https://imgur.com/kTS6Ryt

Here is how I’m including SDL_ttf in main.cpp
https://imgur.com/a/2os3MTt

The compile error is just

fatal error: 'SDL_ttf.h' file not found
#include "SDL_ttf.h"
         ^~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/CMakeTest.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/CMakeTest.dir/all] Error 2
make: *** [all] Error 2

I have SDL2_ttf installed in /Library/Frameworks/
Does anyone have any idea how to fix this issue?
I’ve been trying to get this to compile for a few days now and I’ve just resorted to posting on the SDL forms in case anyone knows how to get SDL_ttf working on Mac…

SDL seems to work fine. I’m able to get a window up and running, but no matter what configuration I try, it can’t ever find TTF.

Using quoted includes is telling the compiler to look in the same directory as main.cpp, where SDL_ttf.h obviously isn’t.

Assuming you’re linking to the SDL_ttf framework, you can either:

  • change your include statement to be #include <SDL_ttf/SDL_ttf.h>
  • or, add /Path/to/SDL_ttf.framework/Headers to your include search path (which is kinda gross, since you’re not supposed to be pointing to files/directories inside a framework)

Also, since you’re using cmake, why not have it generate an Xcode project instead? You can still build from the command-line with xcodebuild. The advantage to this is that you can have Xcode include SDL_ttf.framework in your app bundle, so your users won’t have to install it.

Unfortunately with #include <SDL_ttf/SDL_tt.h> I still get fatal error: 'SDL_ttf/SDL_ttf.h' file not found.

Also, This is the very first time I’m using cmake, I usually just made my Makefiles before. I didn’t even know cmake could generate Xcode projects. I could try looking into it.

RESOLVED!

I did not notice at first that this website Index of /projects/SDL_ttf/release where I was obtaining my dmg for the SDL_ttf framework was sorting by oldest first!!!

Redownloading the newest version fixed my issue.

2 Likes