Problems with rmagik / glibc: `GLIBCXX_3.4.32' not found

Hi! I’ve spent a lot of time setting up my nix system and everything was almost working (after many battles) until I’ve run into this when setting up my dev environment:

internal:/nix/store/s5sd5dwk615m1gwk72i7rd40n40znscd-ruby-3.1.4/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb:37:in require': /nix/store/9fy9zzhf613xp0c3jsjxbjq6yp8afrsv-gcc-12.3.0-lib/lib/libstdc++.so.6: version GLIBCXX_3.4.32’ not found (required by /nix/store/5laiqnyngxgm00vjhhd4drymbnhv3sph-libheif-1.15.2/lib/libheif.so.1) - /nix/store/sahkja71y8m6ycqjhg6ifblh0l4wdwb7-ruby3.1-rmagick-5.3.0/lib/ruby/gems/3.1.0/gems/rmagick-5.3.0/lib/RMagick2.so (LoadError)

I have installed both ruby and rmagic with devbox, so they are both nix packages. Both installed, byt rmagik fails at runtime (opening a rails console will do that). Any idea of what I might try next?

1 Like

I’m having a similar problem when trying to install python packages. GLIBCXX_3.4.32 not found.

It looks like stdenv.cc.cc.lib uses gcc-12.3.0 which only provides GLIBCXX is 3.4.30. I’m not sure how to get nix to use a more recent version of gcc. (Latest version is currently 14.1.1)

Same here, except when trying to install the recently released nodejs_22

$ npm --version
/nix/store/...-nodejs-22.0.0/bin/node: /nix/store/...-gcc-12.3.0-lib/lib/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by /nix/store/...-nodejs-22.0.0/bin/node)

Double check that LD_LIBRARY_PATH is empty.

In my case, LD_LIBRARY_PATH is not empty, since I need some libs for local development. In my configuration.nix I have

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

Where env_packages is my environment.systemPackages containing things like libstdcxx5, libtiff, and proj

Is this not the correct way to set my path through configuration? And if not, how do I use pre-compiled libraries that are used in my work repository?

Emptying my LD_LIBRARY_PATH and instead using nix-ld (GitHub - Mic92/nix-ld: Run unpatched dynamic binaries on NixOS) to build my paths did the trick.

LD_LIBRARY_PATH is the correct environment variable to set.

The system configuration’s environment.sessionVariables is the wrong place to set it.

It’s better to set it in a nix shell. If you’re unfamiliar with writing a shell.nix file, there’s a tutorial on nix.dev, and the reference documentation for mkShell in the nixpkgs manual.

I think it’s worth explaining about how LD_LIBRARY_PATH being set relates to “GLIBCXX_ not found”.

On Linux, programs linked against shared libraries are run with the dynamic linker. This is similar to how running ./foo.sh uses the shebang #!/usr/bin/env bash to run/interpret the file.

Some further reading: this article with a simple demonstration about the dynamic linker from baedung.com, this unix.stackexchange question What is /lib64/ld-linux-x86-64.so.2 and why can it be used to execute file? (with an answer linking to an in-depth LWN article about how ELF binaries get run).

The man page for ld-linux points out that it uses the LD_LIBRARY_PATH to indicate where to look for shared libraries.

On NixOS, a dynamic linker has a path like /nix/store/35pq4hr29c3sl79lgfwgsvd9nwzyp4am-glibc-2.39-5/lib64/ld-linux-x86-64.so.2.

So, setting LD_LIBRARY_PATH helps when e.g. using Python packages with pre-compiled shared binaries, since it helps Python find those shared libraries.

But, setting it globally also means that all programs are going to pick up the same version of glibc (or other libraries on LD_LIBRARY_PATH). Programs packaged with Nix (if packaged correctly) should be able to find the shared libraries they depend on without LD_LIBRARY_PATH being set. And apparently can fail with LD_LIBRARY_PATH set to include incompatible versions of libraries they’re linked against.

1 Like

Hi, I’m having the same problem with fcitx-bamboo

E2024-05-27 10:48:19.811578 addonloader.cpp:38] Failed to load library for addon bamboo on /nix/store/0n2b8b27i3hjq6zg422c5g1a6mhqzwx1-fcitx5-with-addons-5.1.5/lib/fcitx5/libbamboo.so. Error: /nix/store/hc0jij4wmrcdrad7fd381r4x2j12d550-gcc-12.3.0-lib/lib/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by /nix/store/0n2b8b27i3hjq6zg422c5g1a6mhqzwx1-fcitx5-with-addons-5.1.5/lib/fcitx5/libbamboo.so)

What should i do? unset LD_LIBRARY_PATH in terminal and run fcitx there didnt work
I didnt set LD_LIBRARY_PATH but it seems to point to pipewire jack

> echo $LD_LIBRARY_PATH                                                                
/nix/store/pa87v5wbpwj75c553pnl3h2x8yr3lbmr-pipewire-1.0.1-jack/lib

pipewire jack setting LD_LIBRARY_PATH is done by the nixos module nixpkgs/nixos/modules/services/desktops/pipewire/pipewire.nix at 9d29cd266cebf80234c98dd0b87256b6be0af44e · NixOS/nixpkgs · GitHub so I wouldn’t worry about that. (Rather: the problems with setting LD_LIBRARY_PATH and glibc are related to putting a glibc in LD_LIBRARY_PATH; I’d expect putting jack lib on the ld library path won’t affect loading glibc).

Reformatting the error you provided so that it’s easier to read:

E2024-05-27 10:48:19.811578 addonloader.cpp:38]
Failed to load library for addon bamboo on
/nix/store/0n2b....zwx1-fcitx5-with-addons-5.1.5/lib/fcitx5/libbamboo.so.
Error: /nix/store/hc0ji....d550-gcc-12.3.0-lib/lib/libstdc++.so.6:
version `GLIBCXX_3.4.32' not found
(required by /nix/store/0n2b....zwx1-fcitx5-with-addons-5.1.5/lib/fcitx5/libbamboo.so)

How did you build the fcitx5-with-addons, and what code did you use for the fcitx-bamboo addon?

Fcitx5-bamboo only exist in unstable so i use the overlay

  i18n.inputMethod = {
    enabled = "fcitx5";
    fcitx5.addons = with pkgs; [
      fcitx5-gtk
      libsForQt5.fcitx5-qt
      fcitx5-configtool
      fcitx5-unikey
      unstable.fcitx5-bamboo
    ];
  };


/nix/store/hc0ji....d550-gcc-12.3.0-lib/lib/libstdc++.so.6

Okay, so it seems that GLIBCXX_3.4.32 is found in gcc13 not 12. I tried running a shell with gcc13 and launch fcitx5 from there, it linked the 12 version still. Might the problem be that I use stable channel for the system and unstable pkgs for bamboo?

Yup.

Perhaps try: (unstable.fcitx5-bambo.override (prevAttrs: builtins.intersectAttrs prevAttrs pkgs))

1 Like

It’s fixed. Thank you so much!

I’m having a similar problem today.

I have a flake with a nixpkgs pointing to 24.05

inputs.nixpkgs.legacyPackages.x86_64-linux.stdenv.cc.cc shows it’s gcc-13.2.0

But when I run my package, I get

/nix/store/c28gplkk35ziwqb8fgnv7609b9i0haym-ruby-3.3.0/lib/ruby/3.3.0/bundled_gems.rb:74:in `require': /nix/store/dghjv6hfz0s0z4kffa5ahyw2mhp79215-gcc-12.3.0-lib/lib/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by /nix/store/1ki1ndr6ql3ij0avqdpym0nw7k7lbnjz-proj-9.4.1/lib/libproj.so.25) - /nix/store/bp71h96qrmngnlmxmcqf3c9awvmdj831-ruby3.3-rgeo-proj4-4.0.0/lib/ruby/gems/3.3.0/gems/rgeo-proj4-4.0.0/lib/rgeo/coord_sys/proj4_c_impl.so

Note that I have no LD_LIBRARY_PATH set.

Any idea why it would be looking for GLIBCXX_3.4.32 in gcc-12 intead of 13?
When I do an ldd on libproj.so.25 it shows:

libstdc++.so.6 => /nix/store/xvzz97yk73hw03v5dhhz3j47ggwf1yq1-gcc-13.2.0-lib/lib/libstdc++.so.6

EDIT: Found the issue!

It was due to the ruby_3_3 package I was using, which was somehow linked to gcc-12. I found that looking at my package in details with nix-tree.