libsdl2-ttf-dev and libsdl2-dev headers not at the same place, causing compilation error

Bug #1872023 reported by Samuel Hangouët
32
This bug affects 7 people
Affects Status Importance Assigned to Milestone
libsdl2-ttf (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Since update to focal, libsdl2 and libsdl2-ttf headers have a different location, causing a compilation error when trying to include SDL2/SDL_ttf.h header :

$ sudo apt install libsdl2-ttf-dev libsdl2-dev
$ echo "#include <SDL2/SDL_ttf.h>" > main.c
$ gcc main.c
In file included from main.c:1:
/usr/include/SDL2/SDL_ttf.h:34:10: fatal error: SDL.h: Aucun fichier ou dossier de ce type
   34 | #include "SDL.h"
      | ^~~~~~~
compilation terminated.

It seems that SDL_ttf.h header expects to be in the same place that SDL ones, which is not the case :

$ dpkg -L libsdl2-ttf-dev
/.
/usr
/usr/include
/usr/include/SDL2
/usr/include/SDL2/SDL_ttf.h
...

$ dpkg -L libsdl2-dev
/.
/usr
/usr/bin
/usr/bin/sdl2-config
/usr/include
/usr/include/x86_64-linux-gnu
/usr/include/x86_64-linux-gnu/SDL2
/usr/include/x86_64-linux-gnu/SDL2/SDL.h
...

Tags: focal
summary: - libsdl2-ttf-dev headers and libsdl2-dev headers not at the same place,
- causing compilation error
+ libsdl2-ttf-dev and libsdl2-dev headers not at the same place, causing
+ compilation error
description: updated
affects: launchpad → libsdl
affects: libsdl → libsdl2-ttf (Ubuntu)
tags: added: focal
Revision history for this message
Samuel Hangouët (samuel-hangouet) wrote :

Since last update, the problem has moved, now this error happens:

In file included from /usr/include/SDL2/SDL.h:32:
In file included from /usr/include/SDL2/SDL_main.h:25:
In file included from /usr/include/SDL2/SDL_stdinc.h:31:
In file included from /usr/include/SDL2/SDL_config.h:4:
In file included from /usr/include/x86_64-linux-gnu/SDL2/_real_SDL_config.h:33:
/usr/include/x86_64-linux-gnu/SDL2/SDL_platform.h:179:10: fatal error: 'begin_code.h' file not found
#include "begin_code.h"

A workaround is to add -I/usr/include/SDL2 into compiling flags, but not very clean.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in libsdl2-ttf (Ubuntu):
status: New → Confirmed
Revision history for this message
Alexandre-Xavier Labonté-Lamoureux (alexandrexavier) wrote :

I was trying to build my project using Clang++ instead of G++ and I got this issue. I don't use libsdl2-ttf-dev inside my project, but it's installed on my system. I do use SDL2 and SDL2_image. To be clear, G++ compiles my project fine. Clang++ does not. It spits build errors very similar to this one:

1 error generated.
In file included from ticcmd.cpp:22:
In file included from /usr/include/SDL2/SDL_endian.h:31:
In file included from /usr/include/SDL2/SDL_stdinc.h:31:
In file included from /usr/include/SDL2/SDL_config.h:4:
In file included from /usr/include/x86_64-linux-gnu/SDL2/_real_SDL_config.h:33:
/usr/include/x86_64-linux-gnu/SDL2/SDL_platform.h:179:10: fatal error: 'begin_code.h' file not found

My project: https://github.com/AXDOOMER/MeshGlide

Samuel's workaround worked. I was able to compile my project like this:

clang++ *.cpp -std=c++14 -g -lglfw -lGL -lGLU -lSDL2 -lSDL2_image -lzmq -I/usr/include/SDL2 -o MeshGlide

Revision history for this message
Paweł Kotiuk (pktiuk) wrote :

In my case this issue seems to be a bit random.
I get this error randomly when I try to rebuild my CMake project.
```
usr/include/x86_64-linux-gnu/SDL2/SDL_platform.h:179:10: fatal error: 'begin_code.h' file not found
```
When it appears I have to remove entire build folder for my app and rebuild it.
My app: https://github.com/AntiMicroX/antimicrox

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.