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

how to link static libs? #104

Open
Its-Kenta opened this issue May 3, 2023 · 0 comments
Open

how to link static libs? #104

Its-Kenta opened this issue May 3, 2023 · 0 comments

Comments

@Its-Kenta
Copy link

Its-Kenta commented May 3, 2023

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?

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

1 participant