Skip to content

libLLVM isn't working as expected #157

Open
@NickStrupat

Description

@NickStrupat

It's my understanding (could be wrong) that if I don't expect LLVM to be installed on the machine running my program, I should install the libLLVM package so it will output the LLVM library alongside my program.

Assuming that's correct so far, when my csproj is like so:

<Project Sdk="Microsoft.NET.Sdk">
	<PropertyGroup>
		<OutputType>Exe</OutputType>
		<TargetFramework>net5.0</TargetFramework>
	</PropertyGroup>
	
	<ItemGroup>
		<PackageReference Include="LLVMSharp" Version="11.0.0-beta" />
		<PackageReference Include="libLLVM" Version="11.0.0" />
	</ItemGroup>
</Project>

...and my Program.cs is like so:

using LLVMSharp.Interop;
using System;

using var module = LLVMModuleRef.CreateWithName("NativeBinary");

I get this exception, indicating that it can't find the runtime library.

System.DllNotFoundException
  HResult=0x80131524
  Message=Unable to load DLL 'libLLVM' or one of its dependencies: The specified module could not be found. (0x8007007E)
  Source=LLVMSharp
  StackTrace:
   at LLVMSharp.Interop.LLVM.ModuleCreateWithName(SByte* ModuleID)
   at LLVMSharp.Interop.LLVMModuleRef.CreateWithName(ReadOnlySpan`1 ModuleID) in /_/sources/LLVMSharp/Interop.Extensions/LLVMModuleRef.cs:line 94
   at LLVMSharp.Interop.LLVMModuleRef.CreateWithName(String ModuleID) in /_/sources/LLVMSharp/Interop.Extensions/LLVMModuleRef.cs:line 89
   at <Program>$.<Main>$(String[] args) in C:\Dev\LLVM-Dotnet-Testing\Program.cs:line 4

The workaround I used is to specify my specific runtime by referencing package libLLVM.runtime.win-x64. While this works, I'd like to be able to build and have it output all the runtimes. Or, build specifically for a runtime with an RID and have it output the necessary libLLVM.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions