搞了好久才把3d slicer中的VTK编译通过,现在记录分享一下。
vs2022的错误提示为:
严重性 代码 说明 项目 文件 行 禁止显示状态
错误 MSB8066 “D:\s\b\CTK-build\CTK-build\CMakeFiles\b6944f76527bfb9d477ef678fd9e2af9\org_commontk_CTKDICOMWidgets_init.cpp.rule;D:\s\b\CTK-build\CTK-build\CMakeFiles\b6944f76527bfb9d477ef678fd9e2af9\moc_org_commontk_CTKDICOMWidgets.cpp.rule;D:\s\b\CTK-build\CTK-build\CMakeFiles\3a4383f7f0c0eac08a23f4569546eb3f\moc_ctkDICOMWidgetsPythonQtDecorators.cpp.rule;D:\s\b\CTK\Libs\DICOM\Widgets\CMakeLists.txt”的自定义生成已退出,代码为 1。 [D:\s\b\CTK-build\CTK-build\Libs\DICOM\Widgets\CTKDICOMWidgetsPythonQt.vcxproj] [D:\s\b\CTK-build\CTK.vcxproj] CTK D:\vs2022\install\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets 249
严重性 代码 说明 项目 文件 行 禁止显示状态
错误 MSB8066 “D:\s\b\CTK-build\CMakeFiles\11839b77fb3f2d36191c18dfcc6dd282\CTK-mkdir.rule;D:\s\b\CTK-build\CMakeFiles\11839b77fb3f2d36191c18dfcc6dd282\CTK-download.rule;D:\s\b\CTK-build\CMakeFiles\11839b77fb3f2d36191c18dfcc6dd282\CTK-update.rule;D:\s\b\CTK-build\CMakeFiles\11839b77fb3f2d36191c18dfcc6dd282\CTK-patch.rule;D:\s\b\CTK-build\CMakeFiles\11839b77fb3f2d36191c18dfcc6dd282\CTK-configure.rule;D:\s\b\CTK-build\CMakeFiles\11839b77fb3f2d36191c18dfcc6dd282\CTK-build.rule;D:\s\b\CTK-build\CMakeFiles\11839b77fb3f2d36191c18dfcc6dd282\CTK-forceconfigure.rule;D:\s\b\CTK-build\CMakeFiles\11839b77fb3f2d36191c18dfcc6dd282\CTK-install.rule;D:\s\b\CTK-build\CMakeFiles\a6264ad284c4df7f9f02de652bb19c60\CTK-complete.rule;D:\s\b\CTK-build\CMakeFiles\765f2a14657ca7423beed2b830728c1e\CTK.rule;D:\s\b\CTK\CMakeLists.txt”的自定义生成已退出,代码为 1。 [D:\s\b\CTK-build\CTK.vcxproj] CTK D:\vs2022\install\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets 249
严重性 代码 说明 项目 文件 行 禁止显示状态
错误 MSB8066 “D:\s\b\CMakeFiles\cefbea8588ddd530aef80f712c894c69\CTK-download.rule;D:\s\b\CMakeFiles\cefbea8588ddd530aef80f712c894c69\CTK-update.rule;D:\s\b\CMakeFiles\cefbea8588ddd530aef80f712c894c69\CTK-patch.rule;D:\s\b\CMakeFiles\cefbea8588ddd530aef80f712c894c69\CTK-configure.rule;D:\s\b\CMakeFiles\cefbea8588ddd530aef80f712c894c69\CTK-build.rule;D:\s\b\CMakeFiles\cefbea8588ddd530aef80f712c894c69\CTK-generate_project_description.rule;D:\s\b\CMakeFiles\cefbea8588ddd530aef80f712c894c69\CTK-install.rule;D:\s\b\CMakeFiles\b5b4404f8cf976e333e8e4ce8264aa13\CTK-complete.rule;D:\s\b\CMakeFiles\76cd70aee860ab4c8fa1377c16e6dea5\CTK.rule”的自定义生成已退出,代码为 1。 CTK D:\vs2022\install\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets 249
在…/CTK-build/x64/Debug/CTK中找到VTK.log编译的提示:
PythonQt Wrapping - Generating generated_cpp/org_commontk_CTKDICOMWidgets/org_commontk_CTKDICOMWidgets_init.cpp
Traceback (most recent call last):
File "D:\s\b\CTK\CMake\ctkWrapPythonQt.py", line 252, in <module>
ctk_wrap_pythonqt(options.target, options.namespace, options.output_dir, args, options.extra_verbose)
File "D:\s\b\CTK\CMake\ctkWrapPythonQt.py", line 93, in ctk_wrap_pythonqt
content = f.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0xbf in position 2: illegal multibyte sequence
定位到问题
File "D:\s\b\CTK\CMake\ctkWrapPythonQt.py", line 93, in ctk_wrap_pythonqt
content = f.read()
用everything搜到文件:ctkWrapPythonQt.py,第93行,修改原代码:
# Read input files
with open(input_file) as f:
content = f.read()
为
# Read input files
with open(input_file, 'r', encoding='utf-8') as f:
content = f.read()
使用UTF-8打开文件,保存,重新编译VTK项目。
有用的一些参考,csdn的编辑器不能实现粘贴edge的文字超链接的格式,只能点进去看了:
https://blog.csdn.net/qq_41368848/article/details/129077347
https://blog.csdn.net/yaoxingdong/article/details/108051384
https://blog.csdn.net/CodeWorld1999/article/details/134655055