Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ubuntu libclang still not resolved #586

Open
GideonUng opened this issue Dec 13, 2024 · 4 comments
Open

Ubuntu libclang still not resolved #586

GideonUng opened this issue Dec 13, 2024 · 4 comments

Comments

@GideonUng
Copy link

GideonUng commented Dec 13, 2024

What dlls and to where. how do i get libclang.so files from Nuget even? the links to Nuget dont have any so files in them. what even are the limitations of dotnet that this isnt possible.

is it even possible to run this tool under linux currently. this has been an issue for years and there is neither a fix nor any semblance of documentation regarding this.

"Please see https://github.com/dotnet/clangsharp for more details." there are exactly no more details at https://github.com/dotnet/clangsharp

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/gidcheen/.dotnet/tools/.store/clangsharppinvokegenerator/18.1.0.2/clangsharppinvokegenerator/18.1.0.2/tools/net8.0/any/libClangSharp.so: cannot open shared object file: No such file or directory
/usr/lib/dotnet/shared/Microsoft.NETCore.App/8.0.10/libClangSharp.so: cannot open shared object file: No such file or directory
/home/gidcheen/.dotnet/tools/.store/clangsharppinvokegenerator/18.1.0.2/clangsharppinvokegenerator/18.1.0.2/tools/net8.0/any/liblibClangSharp.so: cannot open shared object file: No such file or directory
/usr/lib/dotnet/shared/Microsoft.NETCore.App/8.0.10/liblibClangSharp.so: cannot open shared object file: No such file or directory
/home/gidcheen/.dotnet/tools/.store/clangsharppinvokegenerator/18.1.0.2/clangsharppinvokegenerator/18.1.0.2/tools/net8.0/any/libClangSharp: cannot open shared object file: No such file or directory
/usr/lib/dotnet/shared/Microsoft.NETCore.App/8.0.10/libClangSharp: cannot open shared object file: No such file or directory
/home/gidcheen/.dotnet/tools/.store/clangsharppinvokegenerator/18.1.0.2/clangsharppinvokegenerator/18.1.0.2/tools/net8.0/any/liblibClangSharp: cannot open shared object file: No such file or directory
/usr/lib/dotnet/shared/Microsoft.NETCore.App/8.0.10/liblibClangSharp: cannot open shared object file: No such file or directory

at ClangSharp.Interop.clangsharp.getVersion()
at ClangSharp.PInvokeGenerator..ctor(PInvokeGeneratorConfiguration config, Func2 outputStreamFactory) in /_/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs:line 111 at ClangSharp.Program.Run(InvocationContext context) in /_/sources/ClangSharpPInvokeGenerator/Program.cs:line 733 at System.CommandLine.Handler.<>c__DisplayClass1_01.b__0(InvocationContext context)
at System.CommandLine.Invocation.AnonymousCommandHandler.<>c__DisplayClass2_0.<.ctor>g__Handle|0(InvocationContext context)
at System.CommandLine.Invocation.AnonymousCommandHandler.InvokeAsync(InvocationContext context)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass18_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass13_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass20_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<b__19_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass17_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<b__6_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass9_0.<b__0>d.MoveNext()

@tannergooding
Copy link
Member

there are exactly no more details at https://github.com/dotnet/clangsharp

From the main README:

A nuget package for the project is provided here: https://www.nuget.org/packages/clangsharp. A .NET tool for the P/Invoke generator project is provided here: https://www.nuget.org/packages/ClangSharpPInvokeGenerator

NOTE: 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.

A convenience package which provides the native libClang library for several platforms is provided here: https://www.nuget.org/packages/libclang

A helper package which exposes many Clang APIs missing from libClang is provided here: https://www.nuget.org/packages/libClangSharp

NOTE: libclang and libClangSharp are meta-packages which point to the platform-specific runtime packages ([e.g.](https://www.nuget.org/packages/libClangSharp.runtime.win-x64/18.1.3); see others owned by [tannergooding](https://www.nuget.org/profiles/tannergooding)). Several manual steps may be required to use them, see discussion in https://github.com/dotnet/ClangSharp/issues/46 and https://github.com/dotnet/ClangSharp/issues/118.

Nightly packages are available via the NuGet Feed URL: https://pkgs.clangsharp.dev/index.json

Source browsing is available via: https://source.clangsharp.dev/

In particular:

NOTE: libclang and libClangSharp are meta-packages which point to the platform-specific runtime packages ([e.g.](https://www.nuget.org/packages/libClangSharp.runtime.win-x64/18.1.3); see others owned by [tannergooding](https://www.nuget.org/profiles/tannergooding)). Several manual steps may be required to use them, see discussion in https://github.com/dotnet/ClangSharp/issues/46 and https://github.com/dotnet/ClangSharp/issues/118.

The discussions cover the meta packages and how you would need to grab the binary from https://www.nuget.org/packages/libclang.runtime.linux-x64. They also cover more in depth some of the issues/problems.


The main issue here is that there are no ways to provide OS specific versions of global tools; including all native dependencies is itself problematic and bloats the tool significantly.

Cloning the repo and running the tool directly from source works as well, as it automatically acquires the Linux package. There are multiple issues logged against NuGet and other locations covering the issue around native dependencies; but such scenarios are relatively rare/niche in the overall ecosystem; particularly for scenarios like global tools; so it hasn't bubbled up in priority for the teams to focus on.

There isn't really anything that ClangSharp can do itself either; there are technically some automation like things that could be attempted but they are problematic, potential security risks, etc and are not good practice to be handled by the tool itself in some attempt to self-bootstrap.

@GideonUng
Copy link
Author

where do the .so files need to be copied to? i assume ~/.dotnet/tools/.store/clangsharppinvokegenerator/18.1.0.2/clangsharppinvokegenerator/18.1.0.2/tools/net8.0/any
but that does not seem to work and produce the same error.

@GideonUng
Copy link
Author

the actual issue seems to have been that libClangSharp.so does not depend on libclang.so but libclang.so.18.1 which doesnt get installed by apt and wasnt the name of the libclang from the nuget package.
is this meant to be this way?

@tannergooding
Copy link
Member

is this meant to be this way?

Yes, because Clang makes breaking changes every release and it must bind against an exact version. A lot of more fundamental issues can occur if it happens to mismatch.

which doesnt get installed by apt

This is strange... All the Ubuntu packages I've tested against install an exact version and then create the libclang.so file as a symlink to that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants