Segmentation fault after manually building libClangSharp.so
I'm following this tutorial on how to generate C# interop bindings for a clang library.
After doing dotnet tool install --global ClangSharpPInvokeGenerator --version 16.0.0. I got a missing file error, so I followed the instructions to manually build the missing library.
ClangSharpPInvokeGenerator --file ../library/api_client/public/include/api_client.h -n api --methodClassName apiClient -o ./apiClient.cs --libraryPath api
*****IMPORTANT*****
Failed to resolve libClangSharp.
If you are running as a dotnet tool, you may need to manually copy the appropriate DLLs from NuGet due to limitations in the dotnet tool support. Please see https://github.com/dotnet/clangsharp for more details.
*****IMPORTANT*****
Unhandled exception: System.DllNotFoundException: Unable to load shared library 'libClangSharp' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable:
/home/dan/.dotnet/tools/.store/clangsharppinvokegenerator/16.0.0/clangsharppinvokegenerator/16.0.0/tools/net7.0/any/libClangSharp.so: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.14/libClangSharp.so: cannot open shared object file: No such file or directory
/home/dan/.dotnet/tools/.store/clangsharppinvokegenerator/16.0.0/clangsharppinvokegenerator/16.0.0/tools/net7.0/any/liblibClangSharp.so: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.14/liblibClangSharp.so: cannot open shared object file: No such file or directory
/home/dan/.dotnet/tools/.store/clangsharppinvokegenerator/16.0.0/clangsharppinvokegenerator/16.0.0/tools/net7.0/any/libClangSharp: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.14/libClangSharp: cannot open shared object file: No such file or directory
/home/dan/.dotnet/tools/.store/clangsharppinvokegenerator/16.0.0/clangsharppinvokegenerator/16.0.0/tools/net7.0/any/liblibClangSharp: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.14/liblibClangSharp: cannot open shared object file: No such file or directory
I followed the instructions described in the README.md and managed to build libClangSharp. I thought all I'd have to do is cp libClangSharp.so to /home/dan/.dotnet/tools/.store/clangsharppinvokegenerator/16.0.0/clangsharppinvokegenerator/16.0.0/tools/net7.0/any/libClangSharp.so but that's not working. I have confirmed that everything was downloaded and built properly but the hint saying "If you are running as a dotnet tool, you may need to manually copy the appropriate DLLs from NuGet due to limitations in the dotnet tool support. Please see https://github.com/dotnet/clangsharp for more details.". I don't have a DLL, I assumed this hint was telling me to copy libClangSharp.so to the spot mentioned in the error message.
This is the command I ran
ClangSharpPInvokeGenerator --file ../library/api_client/public/include/api_client.h -n api --methodClassName apiClient -o ./apiClient.cs --libraryPath api
And this was its response
1528135 Segmentation fault (core dumped) ClangSharpPInvokeGenerator --file ../library/citrius_client/public/include/citrius_client.h -n Citrius --methodClassName CitriusClient -o ./CitriusClient.cs --libraryPath citrius
System stats:
screenfetch -n
dan@workstation
OS: Manjaro 23.1.0 Vulcan
Kernel: x86_64 Linux 5.15.140-1-MANJARO
Uptime: 9d 17h 45m
Packages: 2371
Shell: zsh 5.9
Resolution: 5760x1080
DE: GNOME
WM: i3
GTK Theme: Adwaita [GTK2/3]
Icon Theme: Adwaita
Font: Cantarell 11
Disk: 450G / 1.9T (26%)
CPU: Intel Core i9-10850K @ 20x 5.2GHz [30.0°C]
GPU: NVIDIA GeForce RTX 2060
RAM: 10190MiB / 64205MiB
How do I correct the segmentation fault so that I can run this program and generate my interop bindings? An AUR repo would be ideal but I need to fix this faster than that.