What package provides libstdc++.so.6?

I am packaging a program which provides a dynamic executable which has a dependency on libstdc++.so.6. What package provides this library? I tried using libstdcxx5, but it doesn’t work and ldd still says libstdc++.so.6 => not found.


stdenv.cc.cc.lib is the general way to reference it, but it’s the libraries of the c/cxx compiler tool chain

Since this seems to get a lot of views, decided to break it down further:

  stdenv     - Wrapper for build environment + default builder
  └─ cc      - Wrapped compiler, which can consume `NIX_...` env variables
    └─ cc    - Unwrapped/unaltered C/CXX compiler, usually GCC (linux) or Clang (MacOS)
      └─ lib - The "lib" output of the unwrapped compiler

For future reference, you can also do this for most files:

$ nix-locate --top-level libstdc++.so.6 | grep gcc
libgccjit.out                                         0 s /nix/store/76vxcz4qm3v22li7dxcvpyn4hl4ivnki-libgccjit-10.3.0/lib/libstdc++.so.6
libgccjit.out                                 1,903,088 x /nix/store/76vxcz4qm3v22li7dxcvpyn4hl4ivnki-libgccjit-10.3.0/lib/libstdc++.so.6.0.28
libgccjit.out                                     2,498 r /nix/store/76vxcz4qm3v22li7dxcvpyn4hl4ivnki-libgccjit-10.3.0/lib/libstdc++.so.6.0.28-gdb.py
gcc-unwrapped.lib                                     0 s /nix/store/x17b1wq871r4ycrxyy1n85ja09dxq3ih-gcc-10.3.0-lib/lib/libstdc++.so.6
gcc-unwrapped.lib                             1,903,088 x /nix/store/x17b1wq871r4ycrxyy1n85ja09dxq3ih-gcc-10.3.0-lib/lib/libstdc++.so.6.0.28
gcc-unwrapped.lib                                 2,494 r /nix/store/x17b1wq871r4ycrxyy1n85ja09dxq3ih-gcc-10.3.0-lib/lib/libstdc++.so.6.0.28-gdb.py

nix-locate comes from the nix-index package, which will index your nix store, so if you already have the package installed, you can inspect which attr produced it.


This has worked to me:

  environment = {
    sessionVariables = {
      LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib";

This is not the way to do it.

This violates nix’ model and assumptions. This little environment variable can break nix packaged software.

If a program from nixpkgs requires this as a “fix”, it is broken and an issue/PR into nixpkgs is appreciated.

If this is for your software which you want to continue using at NixOS, you need to package it and “install” that package the proper way.

If this is for something you are developing, please use nix’ “development shells”.


Hi! It’s not “my” software. It “just” the Microsoft TTS SDK Speech. Well, it worked for me and can be useful for someone else. If its “violate” something I guess the OS should give me a warning or something, but it’s working just fine.

How do you actually get a “development shell”? I am encountering this problem with nix-shell. I’m not overriding stdenv. Before anybody tells me to go read these, I have read them:

At this point you might need to show your nix expression, your code to build and the error.

But creating a shell.nix or a flakes devShells with a derivation that has all the dependencies specified, things usually just work.