Cannot get renderdoc running because it cannot load SDL3

Hi !
I’m quite new to nixos, and I’m trying to rebuild an environment familiar to me.
Today, I tried to install renderdoc, a tool I use in some of my projects.
However, I get the error :

Failed loading SDL3 library.

My project isn’t using SDL3, but SDL2. As far as I read, SDL2 here is just an overlay over SDL3, so the message could still make sense.
What I don’t understand is that if I force SDL3 to be in my environment, using the following nix script :

with import <nixpkgs> {};
stdenv.mkDerivation {
	name = "env";
	nativeBuildInputs = [
		cmake
		gcc
		SDL2
		freetype
		glew
		glm
		doxygen
		graphviz
		upx
	];
	buildInputs = [ SDL2 ];
}

Which I load using (buildDep.nix is the name of the previous file) :

nix-shell buildDep.nix

I still get the same error, even if I run renderdoc from this shell :

qrenderdoc&

Is there something I am missing, or anything I can do to fix this error ?

Thank you !

NB1 : I’m using nix unstable, but the same is true for nixos 25.05, I tested both.
NB2 : I get the same issue with every executable I tried, for instance the packaged version of supertuxkart, which you can launch using :

export SUPERTUXKART_ASSETS_DIR=${SUPERTUXKART_ASSETS_DIR-'/nix/store/f1bvlhphj0ffqdhwvb5iclfic0a7qpzf-stk-assets'}
export SUPERTUXKART_DATADIR=${SUPERTUXKART_DATADIR-'/nix/store/7wpkpb041ss333qwd5hr06wxbilfkyar-supertuxkart-1.4/share/supertuxkart'}

And then by setting /nix/store/7wpkpb041ss333qwd5hr06wxbilfkyar-supertuxkart-1.4/bin/.supertuxkart-wrapped as the executable in renderdoc.

Are you trying to construct a shell to build an application? What is the build system? How are you invoking it? Does the built executable need to be able to locate sdl using dlopen? If so, you need autopatchelf + runtimeDependencies. In your little shell you can ofc call patchelf manually to test the theory. Here is a derivation I wrote that relies on sdl2 and uses autpatchelf. There are tons of examples in nixpkgs, just pull the source and go grepping!

Thanks for you reply !
I want to build an application using cmake, and then to debug it using qrenderdoc.
I have no problem building and running the application outside of qrenderdoc (and I don’t use dlopen), but when I launch it using qrenderdoc, I get the error Failed loading SDL3 library..
For the build process, I create a shell environment using the derivation made with the buildDep.nix script, then I make everything using cmake and make.
I didn’t exactly got how autopatchelf works. However, adding it to the nativeBuildInputs doesn’t solve the issue, and when I run :

auto-patchelf --path build/snake3d

I get the following output :

automatically fixing dependencies for ELF files
{'add_existing': True,
 'append_rpaths': [],
 'extra_args': [],
 'ignore_missing': [],
 'keep_libc': False,
 'libs': [],
 'paths': [PosixPath('build/snake3d')],
 'recursive': True,
 'runtime_dependencies': []}
setting interpreter of build/snake3d
searching for dependencies of build/snake3d
    libSDL2-2.0.so.0 -> not found!
    libfreetype.so.6 -> not found!
    libOpenGL.so.0 -> not found!
    libGLX.so.0 -> not found!
    libGLU.so.1 -> not found!
    libGLEW.so.2.2 -> not found!
    libstdc++.so.6 -> not found!
    libgcc_s.so.1 -> not found!
auto-patchelf: 8 dependencies could not be satisfied
error: auto-patchelf could not satisfy dependency libSDL2-2.0.so.0 wanted by build/snake3d
error: auto-patchelf could not satisfy dependency libfreetype.so.6 wanted by build/snake3d
error: auto-patchelf could not satisfy dependency libOpenGL.so.0 wanted by build/snake3d
error: auto-patchelf could not satisfy dependency libGLX.so.0 wanted by build/snake3d
error: auto-patchelf could not satisfy dependency libGLU.so.1 wanted by build/snake3d
error: auto-patchelf could not satisfy dependency libGLEW.so.2.2 wanted by build/snake3d
error: auto-patchelf could not satisfy dependency libstdc++.so.6 wanted by build/snake3d
error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by build/snake3d
auto-patchelf failed to find all the required dependencies.
Add the missing dependencies to --libs or use `--ignore-missing="foo.so.1 bar.so etc.so"`.

Which I don’t really understand since I have set the environment properly ?
Adding SDL2 or sdl3 to the runtime dependencies doesn’t solve the probleme either.
(Here is the latest version of the buildDep.nix) :

with import <nixpkgs> {};
stdenv.mkDerivation {
	name = "env";
	nativeBuildInputs = [
		autoPatchelfHook
		cmake
		gcc
		SDL2
		freetype
		glew
		glm
		doxygen
		graphviz
		upx
	];
	runtimeDependencies = [
		SDL2
		sdl3
	];
	buildInputs = [ SDL2 ];
}

sdl2-compat relies on the rpath of its shared object which seems to not be respected by renderdoc. You can set the LD_LIBRARY_PATH to the nix path of sdl3 lib before running renderdoc as a workaround, e.g.:

export LD_LIBRARY_PATH=/nix/store/51nk3fvb6hfgnx3x595kpjw59rmqv8hy-sdl3-3.2.24-lib/lib/

is this renderdoc from nixpkgs? nix-shell -p renderdoc --run 'DISPLAY=:0 qrenderdoc (I needed the display var to make it work under xwayland-satellite, you might not) launches just fine. Is it renderdoc throwing the error or thing running under renderdoc (sorry I’ve never used it, so this might be a stupid question :))

Yes, it’s the packaged version. Launching qrenderdoc itself works just fine for me too, but the problem arise when you try to launch an application using the “launch” button :


And the error reported in the terminal is “could not load SDL3”.
I think that this is renderdoc throwing the error, since launching the application without it works just fine, but I’m not completely sure…
(And don’t worry I don’t think it’s a stupid question, thank you for the help between !)

Thank you that did the trick !
Do you know if there is a cleaner way to achieve this result (maybe I should report it as a bug to its developers ?), since this is very hacky (I had to modify the given path with the hash on my computer, which was different from the one given).

Ideally sdl2-compat would just link the sdl3 dynamically instead of dlopening it at runtime. I’ve searched through its options but this doesn’t seem to be supported at the moment. The main sdl lib has such option (SDL_DEPS_SHARED=OFF) so it’s not out of the question for them to add it to the compatibility layer as well.

The other option would be to fix renderdoc to respect the rpath. I don’t have any experience with renderdoc so I don’t know if it’s a hard problem.

1 Like