godotengine / webrtc-native

The official GDNative WebRTC implementation for non-html exports.
MIT License
210 stars 34 forks source link

NixOS error: libstdc++.so.6: cannot open shared object file: No such file or directory #110

Closed Faless closed 1 year ago

Faless commented 1 year ago

There is an issue on NixOS with the libstdc++.so

This is what it does on startup for me.

Editing project: /home/julian/repositories/godot-demo-projects/networking/webrtc_minimal
ERROR: Can't open dynamic library: /home/julian/repositories/godot-demo-projects/networking/webrtc_minimal/webrtc/lib/libwebrtc_native.linux.template_debug.x86_64.so. Error: libstdc++.so.6: cannot open shared object file: No such file or directory
   at: open_dynamic_library (drivers/unix/os_unix.cpp:447)
ERROR: GDExtension dynamic library not found: /home/julian/repositories/godot-demo-projects/networking/webrtc_minimal/webrtc/lib/libwebrtc_native.linux.template_debug.x86_64.so
   at: open_library (core/extension/gdextension.cpp:400)
ERROR: Failed loading resource: res://webrtc/webrtc.gdextension. Make sure resources have been imported by opening the project in the editor at least once.
   at: _load (core/io/resource_loader.cpp:222)
ERROR: Error loading extension: res://webrtc/webrtc.gdextension

(Why is it taking the debug library and not the release version? Does this mean my version of Godot has been compiled as a debug, so this is the compatible one?)

I hacked it so it worked by following @MatthewCroughan's method above:

$ nix build github:nixos/nixpkgs/nixos-unstable#gcc-unwrapped.lib

$ readlink -f result-lib/lib64/libstdc++.so.6
/nix/store/v286z87irid5vn13y2z6fphfrzmgj0kf-gcc-12.3.0-lib/lib/libstdc++.so.6.0.30

$ patchelf --replace-needed libstdc++.so.6 /nix/store/v286z87irid5vn13y2z6fphfrzmgj0kf-gcc-12.3.0-lib/lib/libstdc++.so.6.0.30 ./libwebrtc_native.linux.template_debug.x86_64.so

$ ldd libwebrtc_native.linux.template_debug.x86_64.so
linux-vdso.so.1 (0x00007ffc346fb000)
    /nix/store/v286z87irid5vn13y2z6fphfrzmgj0kf-gcc-12.3.0-lib/lib/libstdc++.so.6.0.30 (0x00007ffa3caa4000)
    libm.so.6 => /nix/store/yaz7pyf0ah88g2v505l38n0f3wg2vzdj-glibc-2.37-8/lib/libm.so.6 (0x00007ffa3c9c4000)
    libgcc_s.so.1 => /nix/store/0fvh2p4irz0lw0cpy2ll1rf2hbhbym3g-xgcc-12.2.0-libgcc/lib/libgcc_s.so.1 (0x00007ffa3c9a3000)
    libc.so.6 => /nix/store/yaz7pyf0ah88g2v505l38n0f3wg2vzdj-glibc-2.37-8/lib/libc.so.6 (0x00007ffa3c7bd000)
    /nix/store/yaz7pyf0ah88g2v505l38n0f3wg2vzdj-glibc-2.37-8/lib64/ld-linux-x86-64.so.2 (0x00007ffa3d54f000)

Now it works, but just for me.

Originally posted by @goatchurchprime in https://github.com/godotengine/webrtc-native/issues/44#issuecomment-1612868018