5

我正在尝试使用on提供的实用程序将一个简单的Java Hello World应用程序编译为本机代码,但我总是遇到错误(见下文)。native-imageGraalVMWindows

HelloWorld.java

public class HelloWorld {
  public static void main(String[] args) {
    System.out.println("Hello, World!");
  }
}

class首先,我使用以下命令将代码编译为文件:

>javac HelloWorld.java

接下来,我native-image从以下调用命令VS 2017 Developer Command Prompt

>native-image -H:+ReportExceptionStackTraces HelloWorld
[helloworld:20420]    classlist:   1,249.05 ms
[helloworld:20420]        (cap):     704.71 ms
[helloworld:20420]        setup:     997.16 ms
Error: Error compiling query code (in C:\Users\User\AppData\Local\Temp\SVM-2348968769537330415\JNIHeaderDirectives.cpp). Compiler command  CL -IC:\GraalVM\include\win32 C:\Users\User\AppData\Local\Temp\SVM-2348968769537330415\JNIHeaderDirectives.cpp /FeC:\Users\User\AppData\Local\Temp\SVM-2348968769537330415\JNIHeaderDirectives.exe output included error: [Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27035 for x86, Copyright (C) Microsoft Corporation.  All rights reserved., ]
com.oracle.svm.core.util.UserError$UserException: Error compiling query code (in C:\Users\User\AppData\Local\Temp\SVM-2348968769537330415\JNIHeaderDirectives.cpp). Compiler command  CL -IC:\GraalVM\include\win32 C:\Users\User\AppData\Local\Temp\SVM-2348968769537330415\JNIHeaderDirectives.cpp /FeC:\Users\User\AppData\Local\Temp\SVM-2348968769537330415\JNIHeaderDirectives.exe output included error: [Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27035 for x86, Copyright (C) Microsoft Corporation.  All rights reserved., ]
        at com.oracle.svm.core.util.UserError.abort(UserError.java:114)
        at com.oracle.svm.hosted.c.NativeLibraries.reportErrors(NativeLibraries.java:218)
        at com.oracle.svm.hosted.NativeImageGenerator.processNativeLibraryImports(NativeImageGenerator.java:1518)
        at com.oracle.svm.hosted.NativeImageGenerator.setupNativeLibraries(NativeImageGenerator.java:1006)
        at com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:835)
        at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:528)
        at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:445)
        at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
Error: Image build request failed with exit status 1

我也尝试了Windows SDK 7.1 Command PromptVS 2019版本,但都没有奏效。如何解决这个问题?它不能是编译器,因为它适用于常规C/C++应用程序。你还需要为此配置什么吗?

4

1 回答 1

0

我设法使用JDK 11各自版本的GraalVM. 例如,可以在此处找到对此的视觉指南(注意:我是视频上传者)。

于 2020-08-20T13:18:30.580 回答