GammaLib.NET 2023.9.11

dotnet add package GammaLib.NET --version 2023.9.11
NuGet\Install-Package GammaLib.NET -Version 2023.9.11
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GammaLib.NET" Version="2023.9.11" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GammaLib.NET --version 2023.9.11
#r "nuget: GammaLib.NET, 2023.9.11"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install GammaLib.NET as a Cake Addin
#addin nuget:?package=GammaLib.NET&version=2023.9.11

// Install GammaLib.NET as a Cake Tool
#tool nuget:?package=GammaLib.NET&version=2023.9.11

Gamma

With C#s incredibly disappointing support for importing unmanaged libraries, I have decided to write a wrapper to import and marshal unmanaged types into managed code. In other words, I would like to introduce Gamma! An all new, niche library I am working on to interop with native libraries.

Supported Platforms

Gamma supports both Windows and Linux, with hopeful future support for OSX!

Keep in mind that on linux, Gamma needs the C standard libraries to be installed to run!

Dependencies

  • Windows: <a href="https://visualstudio.microsoft.com/vs/">Visual Studio Community 2022</a> (Make sure to download the C/C++ tools!) (Or your C compiler of choice)
  • Linux: GCC (or your C compiler of choice)

Getting Started

First lets write our C program!

mylib.c

//Linux
int GetInt()
{
    return 5;
}

//Windows
__declspec(dllexport) int GetInt()
{
    return 5;
}

Now we compile:

Windows (Keep in mind your DLL needs to be for the same architecture as your C# program! See here):

Open x64 Native Tools Command Prompt for VS 2022 (You can literally just search for this in Windows)(Why in the world does this have such a long name?)

Now type:

cl /LD mylib.c

Linux:

gcc mylib.c -o libmylib.o
gcc mylib.o -shared -o libmylib.so

And now we are ready to create our C#!

Windows:

using(LibImporter import = new LibImporter("mylib.dll"))
{
    NativeDelegate<int> getint = import.LoadFunc("GetInt");
    int foo = getint.Invoke();

    Console.WriteLine(foo);
}

Linux:

using(LibImporter import = new LibImporter("libmylib.so"))
{
    NativeDelegate<int> getint = import.LoadFunc("GetInt");
    int foo = getint.Invoke();

    Console.WriteLine(foo);
}

As Seen In

  • <a href="https://github.com/grimtin10/Rainbow/">Rainbow (Grimtin10, YendisFish)</a>
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2023.9.11 123 9/11/2023