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
Native AOT classlib compiles with [DLLImport° as cheating dynamic library #83353
Comments
.NET runtime loads shared libraries dynamically by default. Native AOT has the same default behavior. If you would like the unmanaged shared library to be linked directly such that it shows up in ldd output, add it to This is documented in https://github.com/dotnet/runtime/blob/main/src/coreclr/nativeaot/docs/interop.md#direct-pinvoke-calls |
@jkotas thanks! That's great for direct invoke. That is weird bug. That's not question. It looks like cheating from hidden loading shared libraries who doesn't know to open important shared libraries like Ubuntu 22.04 forgot to install required deps when end user opens native aot compiled dotapps or checks ldd. They think dotnet cheats from forgotten invoking libraries. That's why dotnet made criminally. That's why we need support for improving generation of automatical directinvoke output after native aot compilation and end user will know when dotapp opens by user and throws errors and it says to need to install shared libraries. Thanks! |
Our principle is to avoid unnecessary behavior differences between standard .NET runtime and native AOT compiled binaries. .NET runtime loads shared libraries on demand and number of popular NuGet packages depend on this behavior. We are not going to change the default behavior. It would be a hard-to-justify breaking change. |
Okay that's our decision of dotnet. Thanks for understanding! I will use manual with directinvoke. // EDIT: I already tried.
But it throws error because it doesn't find libX11.a from
Result:
That is catastrophically. If native aot compilation throws error then I add manually copy and past remove libX11.a and find -lrt and add -lX11 and compilation by hand and I prompt then it shows not errors.
Check ldd it is really valid and correct.
That is correctly. but how do I add That is really impossible. But why does dotnet show NativeLibrary's Include with -lc but in directinvoke document is wrong
It should like for Linux only:
That is correct for Unix if you use Linux then you need use If you use pkgconfig like Gtk3 or Gtk4 then you should use Do you think that is correct or wrongly? |
Hello,
Woah I expected that I have written with [DLLImport()] in classlib project
But why does ldd not show if I added DLLImport as l(library-name) I will explain next line...
Example I write
Class1.cs
I check native compiled
example.so
with lddwhat does it happen but native aot won't show when I already use
[DLLImport("libX11")]
as-lX11
in clang / gcc lineResult:
That is unfair because dotnet cheats to load hidden dynamical libraries...
Where is libX11.so.6 from ldd when you have used DLLImport?
Please fix if native aot compilation will convert DLLImport into static library
*.a
then generates to clang's line-l(library-name)
and include-path also.And I try console project:
Result:
And Terminal in VS Code output:
Woah it works fine. But ldd doesn't know where is DLLImport's path-to-library? That is why I need to give suggestion generation of dotnet into static library name like
-lX11
fromlibX11.a
Example:
If you want SDL3 or GLFW3 into native aot via DLLImport and native aot compilation will change DLLImport to library-name like
clang ..... -lSDL3 ...
then somebody checks with
ldd
then it will list in native aot compiled *.so file from classlib project.That is proof from generated path to lib-name. I hope you know about cheating is not allowed. And I want everyone is seriously. I know Dotnet is not cheater. That is why I find bug when native aot doesn't know while you write with
DLLImport
in classlib-project then native aot compiler should catch path if it find *.a "Hu that is valid or current a file of same shared libraries like Windows 10 has dll file and lib file.I would like to imagine about our development if native aot process find path
User32.dll
then it knows -> where is User32.lib and it catches lib file from Windows SDK Installation's Path.Do you think Dotnet native aot compilation can catch static library if somebody uses
DLLImport
and builds end-user application. And shows proof of ldd.Is it realistically?
Thanks!
The text was updated successfully, but these errors were encountered: