ikvm icon indicating copy to clipboard operation
ikvm copied to clipboard

Can't Convert jar to dll

Open LxhSama opened this issue 10 months ago • 14 comments

ikvmc -target:library wxbot1.1.jar have error IKVM.Tools.Importer (8.8.0+Branch.tags-8.8.0.Sha.0dcccd0af21487f20a29138a6a06948503cf8597) Copyright ? 2024 Jeroen Frijters, Windward Studios, Jerome Haltom, Shad Storhaug

Core library not found. Make sure the appropriate reference assemblies for the target environment are included.

*** COMPILER ERROR ***

IKVM.Tools.Importer, Version=8.8.0.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58 C:\Users\Administrator\Downloads\IKVM-8.8.0-bin-net8.0\ikvmc\net8.0\win-x64
8.0.4 64-bit

System.Exception: Exception of type 'System.Exception' was thrown. at IKVM.Tools.Importer.StaticCompiler.Init(Boolean nonDeterministicOutput, DebugMode debug, IList`1 libpaths) in //src/IKVM.Tools.Importer/StaticCompiler.cs:line 72 at IKVM.Tools.Importer.IkvmImporterInternal.Compile(String[] args) in //src/IKVM.Tools.Importer/IkvmImporterInternal.cs:line 178 at IKVM.Tools.Importer.IkvmImporterInternal.Execute(String[] args) in /_/src/IKVM.Tools.Importer/IkvmImporterInternal.cs:line 112

LxhSama avatar Apr 19 '24 03:04 LxhSama

Did you "Make sure the appropriate reference assemblies for the target environment are included?"

wasabii avatar Apr 19 '24 15:04 wasabii

Did you "Make sure the appropriate reference assemblies for the target environment are included?"

Can you clarify? What "core library" are we talking about? What "target environment" are we talking about? What are the "appropriate reference assemblies"? Please don't assume that everyone understands how your app works.

slxdy avatar Apr 21 '24 11:04 slxdy

Did you "Make sure the appropriate reference assemblies for the target environment are included?"

I compiled a utility library using Java 1.8, and then executed the command 'ikvmc -target:library wxbot1.1.jar' via the command line. I used the latest version 8.8 of IKVM.Tools. However, it threw the above error. The JAR file contains dependencies and can be executed correctly. I don't know if what you're saying is about needing me to include something in the Java package.

LxhSama avatar Apr 21 '24 11:04 LxhSama

Every assembly that is part of the target framework you are attempting to link to needs to be available to the compiler. That means -reference to everything like System.Private.CoreLib, System.Runtime, etc, out of the .NET SDK for the version you are targeting; or the appropriate reference assemblies for the version of .NET framework you are targeting, need to be specified on the command line.

wasabii avatar Apr 21 '24 17:04 wasabii

Can you add an argument like -use-current-clr-libs to make it automatically use the libraries that the compiler itself is using? Would make everything way easier

slxdy avatar Apr 21 '24 20:04 slxdy

No. You have to pass every assembly to the C# compiler, too. This has been required since .net core was introduced.

Which the build system does. Which is why we recommend IkvmReference.

wasabii avatar Apr 21 '24 20:04 wasabii

No. You have to pass every assembly to the C# compiler, too. This has been required since .net core was introduced.

Which the build system does. Which is why we recommend IkvmReference. Does that mean that the Tools approach cannot be used directly and instead, using IkvmReference is recommended?

LxhSama avatar Apr 22 '24 01:04 LxhSama

You can use the tools. They are just very hard to use. Same as the csharp compiler these days.

IkvmReference is the only thing mentioned in the README for this reason.

wasabii avatar Apr 22 '24 01:04 wasabii

You can use the tools. They are just very hard to use. Same as the csharp compiler these days.

IkvmReference is the only thing mentioned in the README for this reason.

Wait a second, does IKVM actually generate C# code instead of directly building a CIL assembly?

slxdy avatar Apr 22 '24 08:04 slxdy

No.....

wasabii avatar Apr 22 '24 08:04 wasabii

No.....

But why do you need the system assemblies then? You should only need to know whether youre targeting core or framework

slxdy avatar Apr 22 '24 09:04 slxdy

Because it needs to find types in them.

wasabii avatar Apr 22 '24 11:04 wasabii

Because it needs to find types in them.

You dont actually. Type references can be made from pure names. Actually loading system libraries is just an extra unnecessary step

slxdy avatar Apr 22 '24 12:04 slxdy

We don't know what assemblies they live in unless we look. Same situation as Roslyn. The compiler isn't hard coded to the location of classes in assemblies, since this is subject to change.

wasabii avatar Apr 22 '24 12:04 wasabii