ikvmnet / ikvm

A Java Virtual Machine and Bytecode-to-IL Converter for .NET
Other
1.24k stars 116 forks source link

I'm running into Compiler Error: core library not found #458

Closed chrisrogerskelvion closed 10 months ago

chrisrogerskelvion commented 10 months ago

I'm attempting to use IKVMC.exe to convert a .jar file to a .dll and am getting a compiler error.

C:.nuget\packages\ikvm.msbuild.tools.runtime.win-x64\8.7.1\ikvmc\net6.0\win-x64>ikvmc.exe -target:library -out:MyJar.dll -recurse:"C:.nuget\packages\ikvm.msbuild.tools.runtime.win-x64\8.7.1\ikvmc\net6.0\win-x64\MyJar.jar" IKVM.Tools.Importer (8.7.1+Branch.tags-8.7.1.Sha.e4ff2051f79fc0849223e953f257ca37e2a0f854) Copyright c 2023 Jeroen Frijters, Windward Studios, Jerome Haltom, Shad Storhaug

Error: core library not found

INTERNAL COMPILER ERROR

PLEASE FILE A BUG REPORT FOR IKVM.NET WHEN YOU SEE THIS MESSAGE

IKVM.Tools.Importer, Version=8.7.1.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58 C:\Users\chris.rogers.nuget\packages\ikvm.msbuild.tools.runtime.win-x64\8.7.1\ikvmc\net6.0\win-x64\ 6.0.24 64-bit

System.IO.FileNotFoundException: System.Runtime at IKVM.Reflection.Universe.Load(String refname, Module requestingModule, Boolean throwOnError) in //src/IKVM.Reflection/Universe.cs:line 564 at IKVM.Tools.Importer.AssemblyResolver.Init(Universe universe, Boolean nostdlib, IList1 references, IList1 userLibPaths) in //src/IKVM.Tools.Importer/AssemblyResolver.cs:line 84 at IKVM.Tools.Importer.IkvmImporterInternal.Compile(String[] args) in //src/IKVM.Tools.Importer/IkvmImporterInternal.cs:line 181 at IKVM.Tools.Importer.IkvmImporterInternal.Execute(String[] args) in //src/IKVM.Tools.Importer/IkvmImporterInternal.cs:line 111

wasabii commented 10 months ago

https://github.com/ikvmnet/ikvm/issues/405

You are trying to run a tool out of a NuGet by hand? The intention of packing tools inside of a NuGet is that they are run as part of a build using a specific build methodology. In this case, IkvmReference.

chrisrogerskelvion commented 10 months ago

I cannot access IKVMC inside of a visual studios build due to access modifier levels and namespace recognition issues. Is there a workaround for converting .jars into .dlls such as doing it inside of a console application within visual studio?

wasabii commented 10 months ago

Maybe you should post an issue about those issues instead. I do not exactly know what your workaround suggestion would even entail.

chrisrogerskelvion commented 10 months ago

Do you know of why the internal compiler error is being thrown? Why can it not find the System.Runtime.dll even though it's in the exact same location?

wasabii commented 10 months ago

As described in the duplicate issue I linked to, because it is missing required assemblies. A -reference argument must be passed for every assembly that forms part of the standard SDK you are linking to, and the IKVM.Runtime assembly you want to link to.

Forming this set of arguments is exactly what IkvmReference does, since it runs during the build and has access to the target SDK information you are building for.

chrisrogerskelvion commented 10 months ago

I'm now attempting to use IKVMReference thusly with build errors:

<ItemGroup>
    <IkvmReference Include="..\..\HoneywellPrinterSDK.jar" />
    <AssemblyName>MyAssembly</AssemblyName>
    <AssemblyVersion>3.2.1.0</AssemblyVersion>
    <AssemblyFileVersion>3.0.0.0</AssemblyFileVersion>
    <DisableAutoAssemblyName>true</DisableAutoAssemblyName>
    <DisableAutoAssemblyVersion>true</DisableAutoAssemblyVersion>
    <FallbackAssemblyName>MyAssemblyFallback</FallbackAssemblyName>
    <FallbackAssemblyVersion>3.1.0.0</FallbackAssemblyVersion>
    <KeyFile></KeyFile>
    <DelaySign>true</DelaySign>
    <Compile>HoneywellPrinterSDK.jar</Compile>
    <Sources></Sources>
    <References></References>
    <Aliases>MyAssemblyAlias</Aliases>
    <Debug>true</Debug>
</ItemGroup>

Output: Severity Code Description Project File Line Suppression State Error MSB4232 Items that are outside Target elements must have one of the following operations: Include, Update, or Remove.
Error MSB4232 Items that are outside Target elements must have one of the following operations: Include, Update, or Remove. The project file is invalid on disk and was not reloaded.
Error IKVMSDK0011 The IkvmReference ....\HoneywellPrinterSDK.jar is missing AssemblyName. C:\ikvm\8.7.1\buildTransitive\IKVM.targets 98
Error IKVMSDK0012 The IkvmReference ....\HoneywellPrinterSDK.jar is missing AssemblyVersion. C:\ikvm\8.7.1\buildTransitive\IKVM.targets 98
Error IKVMSDK0013 The IkvmReference ....\HoneywellPrinterSDK.jar is missing AssemblyFileVersion. C:\ikvm\8.7.1\buildTransitive\IKVM.targets 98
Error IKVMSDK0010 The IkvmReference ....\HoneywellPrinterSDK.jar requires at least one Compile item. C:\ikvm\8.7.1\buildTransitive\IKVM.targets 98

wasabii commented 10 months ago

The error message tells you exactly what is wrong here. You have an invalid project file, because elements outside Target elements must be in an ItemGroup. You haven't nested the metadata properties. You might want to read MSs documentation on project files.

wasabii commented 10 months ago

But you've also simply copied every available metadata property. Read through each one to determine if you need it.

chrisrogerskelvion commented 10 months ago

Okay so i've attempted to add a reference argument to the command tool ikvmc.exe but it still is giving a compiler error:

C:\ikvm.msbuild.tools.runtime.win-x64\8.7.1\ikvmc\net6.0\win-x64>ikvmc.exe -target:library -out:HoneyWell_PrinterSDK.dll -recurse:"C:\ikvm.msbuild.tools.runtime.win-x64\8.7.1\ikvmc\net6.0\win-x64\HoneywellPrinterSDK-3.0.153.jar" -runtime:System.Runtime IKVM.Tools.Importer (8.7.1+Branch.tags-8.7.1.Sha.e4ff2051f79fc0849223e953f257ca37e2a0f854) Copyright c 2023 Jeroen Frijters, Windward Studios, Jerome Haltom, Shad Storhaug

Error: core library not found

INTERNAL COMPILER ERROR

PLEASE FILE A BUG REPORT FOR IKVM.NET WHEN YOU SEE THIS MESSAGE

IKVM.Tools.Importer, Version=8.7.1.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58 C:\ikvm.msbuild.tools.runtime.win-x64\8.7.1\ikvmc\net6.0\win-x64\ 6.0.24 64-bit

System.IO.FileNotFoundException: System.Runtime at IKVM.Reflection.Universe.Load(String refname, Module requestingModule, Boolean throwOnError) in /_/src/IKVM.Reflection/Universe.cs:line 564

wasabii commented 10 months ago

A -reference argument must be passed for every assembly that forms part of the standard SDK you are linking to, and the IKVM.Runtime assembly you want to link to.

EVERY ASSEMBLY that forms part of the SDK. There are like 100 of them.

Specifically, if I pick, say, .NET 7.0.14, and look in C:\Program Files\dotnet\packs\Microsoft.NetCore.App.Ref\7.0.14\ref\net7.0 I see 163 assemblies. If I wanted to build against this particular SDK version, I would need 163 -reference arguments, each with the full path.

wasabii commented 10 months ago

Since this isn't a bug, and is also repeated on numerous other issues, I'm going to go ahead and close it now.