C++ stdlib in a python repl for C++ extensions missing (ImportError: libstdc++.so.6: cannot open shared object file)

Hey,

I’m trying to use ujson, a fast JSON parser for python,
it’s a C++ extension, but the issue is I cannot use it, I get
this error:

ImportError: libstdc++.so.6: cannot open shared object file: No such file or directory

I tried looking for it, but I can’t find anything,
any ideas what I could do? Meaning: any way to get
the v6 of C++ stdlib?

2 Likes

I’m also having the same issue while importing ujson Python module.

While i don’t know if we can use it, the libstdc++.so.6 actually exists on /usr/lib/x86_64-linux-gnu/ directory

UPDATE: I seem to have found a fix for this. All you need to do is add a new path in the LD_LIBRARY_PATH environment variable. I did it with the replit.nix configuration file.

env = {
    LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
      pkgs.stdenv.cc.cc.lib
    ];

Now my replit.nix configuration file looks something like this ~

{ pkgs }: {
    deps = [
        pkgs.unzip
        pkgs.python310Packages.setuptools
        pkgs.python310Packages.pip
        pkgs.python310Packages.virtualenv
        pkgs.python310
    ];
    env = {
    LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
      pkgs.stdenv.cc.cc.lib
    ];
    PYTHONBIN = "${pkgs.python310}/bin/python3.10";
    LANG = "en_US.UTF-8";
  };
}
5 Likes

Thank you so much! This resolved the issue. I found that installing certain packages using the ‘Packages’ option can also resolve this issue, but it doesn’t work in all cases for some reason.