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

DLL Not Found on Ubuntu #422

Closed
GideonUng opened this issue Mar 1, 2023 · 4 comments
Closed

DLL Not Found on Ubuntu #422

GideonUng opened this issue Mar 1, 2023 · 4 comments

Comments

@GideonUng
Copy link

I remember this being a bug like a year ago. has this never been fixed?

gidcheen@Laptop:~$ ClangSharpPInvokeGenerator --version
ClangSharp P/Invoke Binding Generator version 15.0.0
  Ubuntu clang version 15.0.6
Failed to resolve libClang or 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.
Unhandled exception: System.DllNotFoundException: Unable to load shared library 'libClangSharp' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibClangSharp: cannot open shared object file: No such file or directory
   at ClangSharp.Interop.clangsharp.getVersion()
   at ClangSharp.Program.Run(InvocationContext context) in /_/sources/ClangSharpPInvokeGenerator/Program.cs:line 269
   at System.CommandLine.Handler.<>c__DisplayClass1_0`1.<SetHandler>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.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass18_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass13_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass20_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__19_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass17_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__6_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass9_0.<<UseExceptionHandler>b__0>d.MoveNext()
@tannergooding
Copy link
Member

As described on other issues (such as #46) this is an issue with .NET Tools and there not being a way to ship RID specific versions of a tool.

Because of that, there is no way to provide libClang or libClangSharp in a way that is guaranteed to "just work". You must manually ensure that the relevant binary is resolvable either by it being installed via your package manager (libClang) or being copied to the folder where the tool was installed (libClangSharp).

If we were to do this in a non-RID specific way, the .NET tool NuGet package (that is the compressed zip) would be 70MB just to support win-x64, osx-x64, and ubuntu-18.04-x64. Adding in -arm64, -x86, or other Linux distros can balloon this further up to 300MB or more.

Please upvote issues such as NuGet/Home#10571 if the scenario is important to you.

@GideonUng
Copy link
Author

i do have libClang installed. including the rest of the llvm toolchain both version 14 and 15

@GideonUng
Copy link
Author

And thats besides the point that if you have external deps like this it has to be part of the installation guide. It doesnt have to work automagically but there is no path for me to find out how to get this working from the documentation.

@tannergooding
Copy link
Member

i do have libClang installed. including the rest of the llvm toolchain both version 14 and 15

As indicated above, there are two native dependencies required here:

  1. libClang
  2. libClangSharp

And thats besides the point that if you have external deps like this it has to be part of the installation guide. It doesnt have to work automagically but there is no path for me to find out how to get this working from the documentation.

The error message explicitly states what's going on and provides a suggestion on how to resolve this

Specifically, it states:

  1. "Failed to resolve libClang or libClangSharp."
  2. "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."
  3. "Unable to load shared library 'libClangSharp' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibClangSharp: cannot open shared object file: No such file or directory"

This tells you, respectively:

  1. There are two possible dependencies that may have failed
  2. The most common source of the failure and how to fix it
  3. Exactly which of the two dependencies caused this specific failure and suggests a way to get more diagnostic information

If there is a way to make this clearer, then suggestions and contributions are welcome. However, as is the error information does state all the required information, particularly when taken in coordination with the repo's README which gives explicit links to the relevant NuGet packages by name.

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