Open sheng-ri opened 6 months ago
Thanks for the feature request! We've got some good news for you: As of https://github.com/oracle/graal/pull/8084, Native Image uses vswhere.exe to locate Visual Studio installations. This make the detection more reliable and it should also support custom installation locations. This feature will be available in the next EA 05 build of GraalVM and will ship with GraalVM for JDK 23.
Please feel free to give this a try and let us know if something is not working for you. Hope this helps!
Thanks for your reply,After my testing there are still problems.
My env
I only download the vs build tool.
https://aka.ms/vs/17/release/vs_BuildTools.exe
Then select msvc and windows 10 sdk.
In this way, you can download msvc without visual studio editor.
Test result
vswhere.exe -version 17.6 -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format json
[]
native-image -jar .\untitled-1.0-SNAPSHOT.jar test
at java.base@23/java.util.Objects.requireNonNull(Objects.java:220)
at java.base@23/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:215)
at java.base@23/java.nio.file.Path.of(Path.java:148)
at java.base@23/java.nio.file.Paths.get(Paths.java:69)
at org.graalvm.nativeimage.driver/com.oracle.svm.driver.WindowsBuildEnvironmentUtil.findVCVarsallWithVSWhere(WindowsBuildEnvironmentUtil.java:114)
at org.graalvm.nativeimage.driver/com.oracle.svm.driver.WindowsBuildEnvironmentUtil.propagateEnv(WindowsBuildEnvironmentUtil.java:53)
at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.buildImage(NativeImage.java:1689)
at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.completeImageBuild(NativeImage.java:1329)
at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.build(NativeImage.java:1880)
at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1845)
at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.main(NativeImage.java:1827)
at java.base@23/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
I'm not sure if vs_BuildTools.exe fulfills the requirements but we should handle the NPE. Thanks for bringing this up!
Feature request
Is your feature request related to a problem? Please describe. For my personal reasons, I need to install msvc and windows sdk in other path, so when using cmd to run native-image, I need run vcvars64 before using native-image. Now i'm try Gradle plugin for GraalVM Native Image building, The previous method is useless.
Describe the solution you'd like. Specify a enviroment path to found vcvarsall or add a arg to specify it.
Describe who do you think will benefit the most. GraalVM users, developers of libraries and frameworks and those tho first try native-image.
Describe alternatives you've considered. for learning purposes,I found these way to solve problem.....
Express whether you'd like to help contributing this feature I apologize, but I don't have the ability to contribute at the moment due to my limitations.