question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

make use of nativeaot static linking feature

See original GitHub issue

Is your feature request related to a problem? Please describe. it is now possible to static link native libraries inside the main binary so it should be possible to do that to the 2 native dlls from avalonia’s native aot output, namely libHarfBuzzSharp.dll and libSkiaSharp.dll.

Describe the solution you’d like include the static library files of those 2 dlls instead and use DirectPInvoke and NativeLibrary.

Additional context https://github.com/dotnet/runtimelab/blob/feature/NativeAOT/docs/using-nativeaot/interop.md#linking

Issue Analytics

  • State:open
  • Created 10 months ago
  • Reactions:1
  • Comments:35 (13 by maintainers)

github_iconTop GitHub Comments

5reactions
maxkatz6commented, Nov 21, 2022

It should be optional, as it works only with native AOT. I suppose ideal plan would be something like:

  • Include lib/a files into our nuget packages. Including Skia and Angle
  • Add new msbuild option to enable avalonia libs static linking
  • In the msbuild targets files include <NativeLibrary> and DirectPInvoke items if avalonia static linking is enabled
  • Exclude dll/so files from the output if avalonia static linking is enabled
3reactions
ivanjxcommented, Feb 18, 2023

you can build skia for other platforms if you look inside the cake files. here is the ones for windows that i use as reference: https://github.com/mono/SkiaSharp/blob/main/native/windows/build.cake

for harfbuzz you can use this and open in visual studio. there is some settings to change to enable static build but i forgot which: https://github.com/mono/SkiaSharp/tree/main/native/windows/libHarfBuzzSharp

reference about the build commands: https://github.com/mono/SkiaSharp/wiki/Building-on-Linux

Read more comments on GitHub >

github_iconTop Results From Across the Web

NativeAOT is one of the most important feature C# needed ...
Static linking does not allow the user access to that "freedom", so the whole binary becomes "infected" and must be open sourced.
Read more >
Static libraries
So we need to add a bunch of static libraries to our link. When Native AOT building a dynamic library, this chore is...
Read more >
Native code interop with native AOT - .NET
To statically link against an unmanaged library, you need to specify <NativeLibrary Include="filename" /> pointing to a .lib file on Windows and ...
Read more >
[NET 7] NativeAOT-compiled static library is not exporting ...
I am trying to compile my managed code into a static library (.lib file on win-x64), so I can link against it from...
Read more >
Can a static library be linked to a .NET AOT compiled ...
This is our C# application. External functions to be linked statically are declared like normal P/Invoke functions. using System.Runtime.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found