You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用Intel编译器运行CMake?编译遇MSB8020错误求助

CMake调用Intel oneAPI DPC++ Compiler时MSB8020错误解决

执行的CMake命令

cmake -G "Visual Studio 17 2022" -A x64 -T "Intel(R) oneAPI DPC++ Compiler" ..

错误日志

-- CMAKE_BUILD_TYPE is unset, defaulting to Release
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.25099.
CMake Error at CMakeLists.txt:81 (project):
Failed to run MSBuild command:
C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe
to get the value of VCTargetsPath:
MSBuild version 17.3.1+2badb37d1 for .NET Framework
Build started 9/2/2022 10:51:43 AM.
Project "C:\Users\mtc\source\repos\onednn\build\CMakeFiles\3.23.1\VCTargetsPath.vcxproj" on node 1 (default targets).
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(460,5): error MSB8020: 找不到Intel(R) oneAPI DPC++ Compiler的构建工具(平台工具集 = 'Intel(R) oneAPI DPC++ Compiler')。
若要使用Intel(R) oneAPI DPC++ Compiler构建工具进行编译,请安装Intel(R) oneAPI DPC++ Compiler构建工具。
或者,您可以通过选择“项目”菜单或右键点击解决方案,然后选择“重新定向解决方案”来升级到当前Visual Studio工具。 [C:\Users\mtc\source\repos\onednn\build\CMakeFiles\3.23.1\VCTargetsPath.vcxproj]
Done Building Project "C:\Users\mtc\source\repos\onednn\build\CMakeFiles\3.23.1\VCTargetsPath.vcxproj" (default targets) -- FAILED

"C:\Users\mtc\source\repos\onednn\build\CMakeFiles\3.23.1\VCTargetsPath.vcxproj" (default target) (1) ->
(PrepareForBuild target) ->
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(460,5): error MSB8020: 找不到Intel(R) oneAPI DPC++ Compiler的构建工具(平台工具集 = 'Intel(R) oneAPI DPC++ Compiler')。若要使用Intel(R) oneAPI DPC++ Compiler构建工具进行编译,请安装Intel(R) oneAPI DPC++ Compiler构建工具。或者,您可以通过选择“项目”菜单或右键点击解决方案,然后选择“重新定向解决方案”来升级到当前Visual Studio工具。 [C:\Users\mtc\source\repos\onednn\build\CMakeFiles\3.23.1\VCTargetsPath.vcxproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.15
Exit code: 1

解决步骤

  • 确认Intel oneAPI DPC++ Compiler已安装并完成VS集成
    打开Intel oneAPI安装管理器,检查是否已安装Intel® oneAPI DPC++ Compiler组件,安装时必须勾选与Visual Studio 2022的集成选项。如果未安装,补充安装该组件;如果已安装但未集成,选择修复安装。

  • 使用Intel专属命令提示符执行编译
    从开始菜单找到Intel oneAPI Command Prompt for Visual Studio 2022,打开后切换到项目的build目录,重新执行原CMake命令。该提示符会自动配置好编译器的环境变量,确保MSBuild能识别到Intel的平台工具集。

  • 检查Visual Studio平台工具集可用性
    打开Visual Studio 2022,新建空C++项目,右键项目→属性→常规→平台工具集,查看是否存在Intel(R) oneAPI DPC++ Compiler选项。若不存在,说明集成失败,需重新安装Intel oneAPI编译器或修复Visual Studio。

  • 升级CMake版本
    当前使用的CMake 3.23.1可能对Intel oneAPI与VS2022的组合支持不足,升级到最新稳定版CMake后重试编译。

内容的提问来源于stack exchange,提问作者Pksingh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 10:10:33