My student made a C app using SDL graphics (SDL2 and a SDL2_ttf font) and I would like to add it to the documentation to help other repliters trying to get SDL running in C or C++. I think there’s a need for this as SDL is a very popular 2D video game development platform, among other things, and the existing documentation search results on “SDL” strongly imply that it’s very difficult if not impossible to use SDL on Replit with C/C++; probably in part because of this bug:
Please see the Makefile in that repl. For some reason, the <SSL2/SDL_ttf.h> include file (from adding pkgs.SDL2.dev and pkgs.SDL2_ttf to replit.nix) tries to #include "SDL.h", which it can’t find without the very lengthy -I/nix/store/xdhh9yzkk2vw7dy2xnl8bgp20gdijj4y-SDL2-2.24.2-dev/include/SDL2
compiler flag, which was very difficult to find (using clang -v -E -x c - < /dev/null 2>&1 | tr ' ' '\n' | grep 'SDL2-.*-dev/include' in the shell.)
How can I work with Replit staff to make sure <SDL2/SDL_ttf.h> can find "SDL.h"?
Expected behavior:
#include "SDL.h" in <SDL2/SDL_ttf.h> should succeed without the hardcoded CFLAGS -I/nix/store/...-SDL2-2.24.2-dev/include/SDL2 flag in the Makefile.
Actual behavior:
In file included from ./view.c:22: /nix/store/29r5cssghd3i1d9h9lmyr3hzgb157zvb-SDL2_ttf-2.20.1/include/SDL2/SDL_ttf.h:39:10: fatal error: 'SDL.h' file not found #include "SDL.h"
Is there a way (for Replit admins?) to change the SDL2_ttf package so that adding it to the deps will automatically add the include/SDL2 path to the CPATH env variable without the user having to explicitly specify it?
Can the CFLAGS similarly be set merely by adding the pkgs deps?
I suppose they could add a Nix module (.replit config) or similar for it. And it would be possible for replit’s nix function which references replit.nix to take in a different [1] attribute for include packages and has an index of the working include folders needed by well-known multi-versioned packages like SDL.
implementing in the existing deps would break compatibility with Nix’s reproducible system ↩︎