Need Help Building An SDL2 Application - fatal error: SDL_config-x86_64.h: No such file or directory

Hi,

I have an SDL2 application I am trying to build on Fedora 40 Cinnamon.
The SDL2 application is using C++.
Addition SDL2 libraries are: SDL2_Image, SDL2_Mixer, and SDL2_TTF.

I have a makefile that worked fine on *ubuntu Linux distro’s.
When I open terminal in folder with makefile, I type “make” but it does not build?
I think I installed all the SDL2 dependencies using Cinnamon Dnfdragora.

Error is below, hope someone can help me:

James

g++ -pipe -Wall -g  -I/usr/include/SDL2 -D_REENTRANT -c src/main.cpp -o src/main.o
In file included from /usr/include/SDL2/SDL_stdinc.h:31,
                 from /usr/include/SDL2/SDL_main.h:25,
                 from /usr/include/SDL2/SDL.h:32,
                 from src/main.cpp:54:
/usr/include/SDL2/SDL_config.h:58:10: fatal error: SDL_config-x86_64.h: No such file or directory
   58 | #include "SDL_config-x86_64.h"
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [makefile:46: src/main.o] Error 1

Makefile is below:

TARGET = tc4ai

VERSION = 4.5

DEL_FILE = rm -f

CC      = g++
CFLAGS = -pipe -Wall -g #-"ggdb"
SDL_CFLAGS = $(shell sdl2-config --cflags)
SDL_LIBS = $(shell sdl2-config --libs) 

SDL_TTF_LIBS	= -lSDL2_ttf
SDL_IMAGE_LIBS	= -lSDL2_image
SDL_MIXER_LIBS  = -lSDL2_mixer

OBJECTS = src/main.o \
          src/audio.o \
          src/data.o \
          src/input.o \
          src/interface.o \
          src/logic.o \
          src/screens.o \
          src/visuals.o

SOURCES = src/main.cpp \
          src/audio.cpp \
          src/data.cpp \
          src/input.cpp \
          src/interface.cpp \
          src/logic.cpp \
          src/screens.cpp \
          src/visuals.cpp

HEADERS = src/audio.h \
          src/data.h \
          src/input.h \
          src/interface.h \
          src/logic.h \
          src/screens.h \
          src/visuals.h

$(TARGET): $(OBJECTS)
	$(CC) $(OBJECTS) $(SDL_LIBS) $(SDL_TTF_LIBS) $(SDL_IMAGE_LIBS) $(SDL_MIXER_LIBS) -o $@

.cpp.o:
	$(CC) $(CFLAGS) $(SDL_CFLAGS) -c $< -o $@

clean:
	rm $(OBJECTS) $(TARGET)

Still same error?

https://bitbucket.org/jesseleepalser/t-crisis_4_sdl2/src/master/

Free MIT license open-source cross-platform

It works for me by following the readme instructions.
Here’s the specfile you can use to create own Copr repo:

sudo dnf install copr-cli

COPR_NAME="tc4ai"
COPR_PKG="${COPR_NAME}"
COPR_HOME="https://jesseleepalser.itch.io/t-crisis-4"
COPR_DESCR=\
"T-Crisis 4 110% A.I. Turbo Remix.

Homepage: [itch.io](${COPR_HOME})"
COPR_INSTR=\
'```sh
sudo dnf install tc4ai
```'

tee /tmp/${COPR_PKG}.sh << "EOI" > /dev/null
#!/usr/bin/bash
tee tc4ai.spec << "EOF" > /dev/null
%global forgeurl https://bitbucket.org/jesseleepalser/t-crisis_4_sdl2
%global commit 765ff4a292532ec6466774b26eae00a7080245cc
%global commitdate 20230506
%global shortcommit %(c=%{commit}; echo ${c:0:12})
%global source_date_epoch_from_changelog 0

Name: tc4ai
Version: 1^%{commitdate}git%{shortcommit}
Release: 1%{?dist}
Summary: T-Crisis 4 110% A.I. Turbo Remix
License: MIT
URL: https://jesseleepalser.itch.io/t-crisis-4
Source0: %{forgeurl}/get/%{commit}.tar.gz#/%{name}-%{shortcommit}.tar.gz
Source1: %{name}.desktop
BuildRequires: make
BuildRequires: gcc-g++
BuildRequires: SDL2-devel
BuildRequires: SDL2_image-devel
BuildRequires: SDL2_mixer-devel
BuildRequires: SDL2_ttf-devel
BuildRequires: desktop-file-utils

%description
https://jesseleepalser.itch.io/t-crisis-4

%prep
%autosetup -n jesseleepalser-t-crisis_4_sdl2-%{shortcommit}

%build
%make_build

%install
install -p -D %{name} %{buildroot}%{_bindir}/%{name}
install -p -d %{buildroot}%{_datadir}/%{name}/data
cp -f -R data/. %{buildroot}%{_datadir}/%{name}/data
desktop-file-install \
--dir=%{buildroot}%{_datadir}/applications \
%{SOURCE1}

%files
%license LICENSE
%doc README.md
%{_bindir}/%{name}
%{_datadir}/%{name}
%{_datadir}/applications/%{name}.desktop
EOF
tee tc4ai.desktop << "EOF" > /dev/null
[Desktop Entry]
Type=Application
Name=T-Crisis 4 110% A.I. Turbo Remix
Categories=Game;
Path=/usr/share/tc4ai
Icon=/usr/share/tc4ai/data/Icon.ico
Exec=tc4ai
EOF
EOI

copr create ${COPR_NAME} \
--chroot fedora-rawhide-$(arch) \
--chroot fedora-$(rpm -E %{fedora})-$(arch) \
--description "${COPR_DESCR}" \
--instructions "${COPR_INSTR}"
copr add-package-custom ${COPR_NAME} \
--name ${COPR_PKG} \
--script /tmp/${COPR_PKG}.sh
copr build-package ${COPR_NAME} \
--name ${COPR_PKG}

Thank you for the info.

Do you know how to package this game for “Flatpak”?

Uninstalled all SDL2 stuff, and carefully reinstalled the required SDL2 stuff.

It builds now:

jlp@fedora:~/Desktop/t-crisis_4_sdl2$ make
g++ -pipe -Wall -g  -I/usr/include/SDL2 -D_REENTRANT -c src/main.cpp -o src/main.o
g++ -pipe -Wall -g  -I/usr/include/SDL2 -D_REENTRANT -c src/audio.cpp -o src/audio.o
g++ -pipe -Wall -g  -I/usr/include/SDL2 -D_REENTRANT -c src/data.cpp -o src/data.o
g++ -pipe -Wall -g  -I/usr/include/SDL2 -D_REENTRANT -c src/input.cpp -o src/input.o
g++ -pipe -Wall -g  -I/usr/include/SDL2 -D_REENTRANT -c src/interface.cpp -o src/interface.o
g++ -pipe -Wall -g  -I/usr/include/SDL2 -D_REENTRANT -c src/logic.cpp -o src/logic.o
g++ -pipe -Wall -g  -I/usr/include/SDL2 -D_REENTRANT -c src/screens.cpp -o src/screens.o
g++ -pipe -Wall -g  -I/usr/include/SDL2 -D_REENTRANT -c src/visuals.cpp -o src/visuals.o
g++ src/main.o src/audio.o src/data.o src/input.o src/interface.o src/logic.o src/screens.o src/visuals.o -lSDL2  -lSDL2_ttf -lSDL2_image -lSDL2_mixer -o tc4ai
jlp@fedora:~/Desktop/t-crisis_4_sdl2$