I’m trying to use SFML with C++ on NixOS. I enter a development environment using:
nix-shell -p sfml pkg-config
But when I try to compile my code:
$ g++ main.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system -lm
/nix/store/v63bxfiacw082c7ijshf60alvvrpfxsq-binutils-2.44/bin/ld: cannot find -lsfml-graphics: No such file or directory
/nix/store/v63bxfiacw082c7ijshf60alvvrpfxsq-binutils-2.44/bin/ld: cannot find -lsfml-window: No such file or directory
/nix/store/v63bxfiacw082c7ijshf60alvvrpfxsq-binutils-2.44/bin/ld: cannot find -lsfml-system: No such file or directory
collect2: error: ld returned 1 exit status
I checked the library directory for SFML (using pkg-config --variable=libdir sfml-graphics
) and noticed that it only contains .a files (static libraries), but no .so files (shared libraries). I want to use dynamic linking(I tried to statically link it dint word more errors), but it seems the SFML package in Nixpkgs is built only with static libraries.
How can I get the .so files or use SFML dynamically in NixOS?