Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cl.exe missing when building native app using GraalVM

I'm trying to build a native application using GraalVM and native-image. An error occures when starting the build process. It seems the cl.exe is missing in the classpath. Like mentioned on the GraalVM website, i've installed the "GRMSDKX_EN_DVD.iso" (Windows SDK for Windows 7 and .NET). I've also tried installing the Windows SDK for Windows 10.

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>native-image -jar C:\Users\tm\Desktop\DemoGraalVM\target\Demo-1.0-SNAPSHOT.jar
[Demo-1.0-SNAPSHOT:28776]    classlist:   2,435.83 ms,  1.16 GB
[Demo-1.0-SNAPSHOT:28776]        setup:     646.59 ms,  1.16 GB
Error: Default native-compiler executable 'cl.exe' not found via environment variable PATH
Error: To prevent native-toolchain checking provide command-line option -H:-CheckToolchain
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Error: Image build request failed with exit status 1

I'm using windows 10, graalvm-ce-java8-windows-amd64-20.2.0. I'm also running Visual Studio Community Edition and use the Visual Studio 2019 Developer Command Prompt v16.3.1. The Java application is build in IntelliJ Community Edition using Maven.

How can I fix this? Where do I download the cl.exe or which installation package contains this file?

like image 902
tmmls Avatar asked Oct 04 '20 16:10

tmmls


1 Answers

I'm sorry you're having trouble; hopefully, we can nip that in the bud real fast!
It looks like you're missing some dependencies, so I'll do my best to clear the issue up for you.


To build a native GraalVM image on Windows, you'll need Microsoft Visual C++ (MSVC). The version required depends on the JDK version that your GraalVM distribution is based on.

  • For a GraalVM distribution using Java 8, you'll need MSVC 2010 SP1

    The recommended installation method is using Microsoft Windows SDK 7.1:

    1. Download the SDK file GRMSDKX_EN_DVD.iso for from Microsoft.
    2. Mount the image by opening F:\Setup\SDKSetup.exe directly.

    According to the GraalVM native-image reference, you can get this easily via the Window SDK 7.1 image from Microsoft

  • For a GraalVM distribution using Java 11, you need MSVC 2017 15.5.5 or later.
    I would definitely recommend just going with the latest version (currently 2019) unless you already use another version in your workflow. You can get it here.


Once you've installed Visual Studio, all of your build commands should be run through the Native Tools Command Prompt.
If you keep the default Start Menu shortcuts while installing Visual Studio, this will be accessible at:
Start -> Visual Studio 2019 -> Tools -> x64 Native Tools Command Prompt


Given that your code is in order, using the proper toolchain will resolve your issues. If any other problems arise, I encourage you to post another question for them; good luck with your project!

like image 68
Zach Avatar answered Oct 15 '22 08:10

Zach