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.

2 Likes

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
8 Likes

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.

4 Likes

This has worked to me:

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

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”.

2 Likes

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:
https://nixos.wiki/wiki/Development_environment_with_nix-shell
https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-develop.html

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.