一、问题描述
使用graalvm编译native-images生成exe文件时报如下错误:无法打开包括文件: “vcruntime.h”: No such file or directory
Error: Error compiling query code (in C:\Users\xxx\AppData\Local\Temp\SVM-8460271372789004913\BuiltinDirectives.c). Compiler command ''E:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe' /WX /W4 /wd4244 /wd4245 /wd4800 /wd4804 /wd4214 '/FeC:\Users\fendo\AppData\Local\Temp\SVM-8460271372789004913\BuiltinDirectives.exe' 'C:\Users\xxx\AppData\Local\Temp\SVM-8460271372789004913\BuiltinDirectives.c'' output included error: [BuiltinDirectives.c, C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\corecrt.h(10): fatal error C1083: 无法打开包括文件: “vcruntime.h”: No such file or directory]
com.oracle.svm.core.util.UserError$UserException: Error compiling query code (in C:\Users\xxx\AppData\Local\Temp\SVM-8460271372789004913\BuiltinDirectives.c). Compiler command ''E:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe' /WX /W4 /wd4244 /wd4245 /wd4800 /wd4804 /wd4214 '/FeC:\Users\fendo\AppData\Local\Temp\SVM-8460271372789004913\BuiltinDirectives.exe' 'C:\Users\xxx\AppData\Local\Temp\SVM-8460271372789004913\BuiltinDirectives.c'' output included error: [BuiltinDirectives.c, C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\corecrt.h(10): fatal error C1083: 无法打开包括文件: “vcruntime.h”: No such file or directory]
二、解决方法
在网上找了一圈没找到相关的解决方法,后面仔细对比环境变量,发现了问题所在:
E:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include
上面是我这边直接复制网上的路径进行修改之后的,与我这边实际的不一样,我这边安装后路径如下:
E:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include
改成自己的路径就行了。以下是完整的环境变量配置:
INCLUDE:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared
E:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include
LIB :
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\x64
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\ucrt\x64
E:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Tools\MSVC\14.29.30133\lib\x64
PATH :
E:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64