bflattened / bflat

C# as you know it but with Go-inspired tooling (small, selfcontained, and native executables)
GNU Affero General Public License v3.0
3.63k stars 104 forks source link

how to link static libs? #104

Open Its-Kenta opened 1 year ago

Its-Kenta commented 1 year ago

Would anyone be able to tell me how this is done? I'm unsure if its similar or close enough to how it's done on .NET or not. But I've been trying to pass the library via --ldflags but it says it fails to find it. I tried to follow the similar steps in DynamicLib example but fails.

For context, I want to mess around with linking a static lib of Raylib and mess around with Interop on Linux.

I have the static library located in the same location as .CS alongside .csproj for testing with .NET NAOT which works perfectly fine.

This is the code I've used:

using System;
using System.Runtime.InteropServices;

partial class Program
{
    [LibraryImport("libraylib")]
    private static partial int GetMonitorCount();

    static void Main() => Console.WriteLine(GetMonitorCount());
}

This worked perfectly fine under .NET and it gave me an executable. However, with bflat, no matter how many different flags I tried and searched around on Issues I keep getting this error:

error CS8795: Partial method 'Program.GetMonitorCount()' must have an implementation part because it has accessibility modifiers.

Does bflat not accept static libraries?