Search code examples
c++ubuntussdl

Can't build SSDL from the source code of the book C++ for the Lazy Programmers


I can't compile the SSDL source code from the book C++ for the Lazy Programmers (2019) by Will Briggs on my ubuntu 20x so could you please tell me what goes wrong? I installed SDL2 and it's working but most of the cases I get the following error when I compile an SSDL code;

cpp-for-lazy-programmers/ch1/hello$ make -f Makefile.unix
g++ -c -g sdl2-config --cflags -I…/…/external/SSDL/include main.cpp -o main.o
In file included from …/…/external/SSDL/include/SSDL.h:27,
from main.cpp:7:
…/…/external/SSDL/include/SSDL_display.h:28:10: fatal error: SDL_ttf.h: No such file or directory
28 | #include <SDL_ttf.h>
| ^~~~~~~~~~~
compilation terminated.
make: *** [Makefile.unix:60: main.o] Error 1 

I just can't understand why SDL_ttf is a big issue as I see many posts regards to SDL_ttf?


Solution

  • Just because they both have "SDL" in the name does not mean they are part of the same library. If you search for SDL_ttf.h on packages.ubuntu.com ("contents of packages"), it will tell you that you want the libsdl2-ttf-dev package

    This is also mentioned in the accompanying documentation.