使用CMake编译assimp库,编译出错,在网上遍寻方法无果,希望有人能指点一二。
操作系统 win10
Windows SDK version 10.0.19041.0
VS 2022
CMake版本 3.24.20
assimp 5.25版本
1.以下是CMake的报错信息
Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044.
CMake Error at CMakeLists.txt:59 (PROJECT):
Failed to run MSBuild command:
D:/Program Files (x86)/VS2022/MSBuild/Current/Bin/amd64/MSBuild.exe
to get the value of VCTargetsPath:
MSBuild version 17.3.1+2badb37d1 for .NET Framework
生成启动时间为 2022/10/10 21:59:16。
节点 1 上的项目“D:\Computer_graphics\assimp-master\build\CMakeFiles\3.24.2\VCTargetsPath.vcxproj”(默认目标)。
PrepareForBuild:
正在创建目录“x64\Debug\”。
正在创建目录“x64\Debug\VCTargetsPath.tlog\”。
InitializeBuildStatus:
正在创建“x64\Debug\VCTargetsPath.tlog\unsuccessfulbuild”,因为已指定“AlwaysCreate”。
PostBuildEvent:
echo VCTargetsPath=D:\Program Files (x86)\VS2022\MSBuild\Microsoft\VC\v170\
:VCEnd
系统找不到指定的路径。
D:\Program Files (x86)\VS2022\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(159,5): error MSB3073: 命令“echo VCTargetsPath=D:\Program Files (x86)\VS2022\MSBuild\Microsoft\VC\v170\ [D:\Computer_graphics\assimp-master\build\CMakeFiles\3.24.2\VCTargetsPath.vcxproj]
D:\Program Files (x86)\VS2022\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(159,5): error MSB3073: :VCEnd”已退出,代码为 1。 [D:\Computer_graphics\assimp-master\build\CMakeFiles\3.24.2\VCTargetsPath.vcxproj]
已完成生成项目“D:\Computer_graphics\assimp-master\build\CMakeFiles\3.24.2\VCTargetsPath.vcxproj”(默认目标)的操作 - 失败。
生成失败。
“D:\Computer_graphics\assimp-master\build\CMakeFiles\3.24.2\VCTargetsPath.vcxproj”(默认目标) (1) ->
(PostBuildEvent 目标) ->
D:\Program Files (x86)\VS2022\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(159,5): error MSB3073: 命令“echo VCTargetsPath=D:\Program Files (x86)\VS2022\MSBuild\Microsoft\VC\v170\ [D:\Computer_graphics\assimp-master\build\CMakeFiles\3.24.2\VCTargetsPath.vcxproj]
D:\Program Files (x86)\VS2022\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(159,5): error MSB3073: :VCEnd”已退出,代码为 1。 [D:\Computer_graphics\assimp-master\build\CMakeFiles\3.24.2\VCTargetsPath.vcxproj]
0 个警告
1 个错误
已用时间 00:00:01.12
Exit code: 1
Configuring incomplete, errors occurred!
See also "D:/Computer_graphics/assimp-master/build/CMakeFiles/CMakeOutput.log".
2.以下是CMakeOutput.log的输出
The system is: Windows - 10.0.19044 - AMD64
3.CMakeList.txt就不列出了
尝试过添加环境变量 VCTargetsPath=D:\Program Files (x86)\VS2022\MSBuild\Microsoft\VC\v170
尝试过下载windows SDK 8.1
尝试过更换SDK版本
尝试过更换CMake版本
尝试过卸载VS2019,下载新的VS2022,结果还是一样的问题
成功编译
1. assimp源码目录下新建 build目录,已存在则删除重建
2. 打开cmd,进入build目录
3. 运行 cmake -G
(查看支持生成的vs列表)
4. 运行 cmake -G "Visual Studio 15 2017" ..
(15 2017 替换成你实际的vs版本)
5. 正常情况下build目录下会生成sln文件,使用vs打开编译
(你这边应该是没有生成这个sln,排查第4步的输出和日志)
CMake报错说无法运行下面这个命令D:/Program Files (x86)/VS2022/MSBuild/Current/Bin/amd64/MSBuild.exe
你查看一下这个MSBuild.exe是否存在?
你好,我在D:\Computer_graphics\assimp-master\build目录下没有生成.sln文件,应该是我CMake无法成功配置生成的原因