VS2022通过WSL2交叉编译失败(疑似libcmake错误)
问题:VS2022通过WSL2编译C++项目CMake配置阶段失败
我尝试将一个简单的C项目编译为ELF格式用于容器化,此前曾短暂成功,但现在通过WSL2编译任何C代码时,均在CMake配置阶段失败。已卸载并重装VS 2022 17.4,甚至回滚了昨日的Windows 11更新,且已在WSL环境中安装了MS cmake,但仍出现cmake库加载异常的错误:
10:26:15.5353681 [Info, Thread 54] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.Services.BuildProjectScannerService: Switching config to linux-debug 10:26:15.5363640 [Info, Thread 50] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.Services.WaitableIndexService: WaitableIndexService listening to IndexService at Completed 10:26:15.5363640 [Info, Thread 47] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.Services.BuildProjectScannerService: OnFileScannerCompleted for CMakeLists.txt 10:26:15.5388714 [Info, Thread 54] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.ParseCache: Canceling all ongoing generations for workspaceDirectory='C:\Users\kenne\source\repos\TestCMake' 10:26:15.5398772 [Warning, Thread 54] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.Services.BuildProjectScannerService: Data is not valid, just removing canceled for CMakeLists.txt linux-debug 10:26:15.5408777 [Info, Thread 53] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.Services.BuildProjectScannerService: Starting scan ... 10:26:15.5428770 [Info, Thread 15] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.Services.BuildProjectScannerService: Scanner Parsing starting: projectfilepath CMakeLists.txt Config Name:linux-debug 10:26:15.5498775 [Info, Thread 53] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.Services.WaitableIndexService: WaitableIndexService listening to IndexService at Completed 10:26:15.5778801 [Info, Thread 47] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.ParseCache: CacheGenerationStarted root: CMAKELISTS.TXTlinux-debug CMakeLists.txt linux-debug 10:26:15.5859133 [Info, Thread 47] Microsoft.VisualStudio.CMake.Linux.Project.RemoteCMakeParser: RemoteCMakeParser ctor 10:26:15.5869118 [Info, Thread 47] libcmake.Linux.RemoteCMakeParser: RemoteCMakeParser ctor 10:26:15.5869118 [Info, Thread 47] Microsoft.VisualStudio.CMake.Linux.Project.RemoteCMakeParser: RemoteCMakeParser finished 10:26:15.5909273 [Error, Thread 47] Microsoft.VisualStudio.CMake.Project.ExternalBuildProject.ProjectProvider: System.MissingMethodException: Method not found: 'Void libcmake.CMakeParameters..ctor(System.String, System.String, libcmake.CMakeConfiguration)'. at libcmake.Linux.RemoteCMakeParameters..ctor(String daemonDirectory, String cmakeListsDirectory, Func`1 remoteSourceFilesDirectoryResolver, Func`1 remoteCMakeListsTxtDirectoryResolver, CMakeConfiguration config) at Microsoft.VisualStudio.CMake.Linux.Project.RemoteCMakeParserProvider.GetCMakeParameters(String cmakeListsFileOrDirectory, CMakeWorkspaceConfiguration cmakeConfiguration, String workspaceDirectory) at Microsoft.VisualStudio.CMake.Project.Utils.<GetCMakeParametersAsync>d__35.MoveNext() End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.CMake.Project.ExternalBuildProject.ProjectProvider.<ParseProjectAsync>d__46.MoveNext() 10:26:15.5909273 [Error, Thread 47] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.ParseCache: Unknown exception during cache generation: root: CMAKELISTS.TXTlinux-debug CMakeLists.txt linux-debug 10:26:15.5919103 [Error, Thread 47] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.ParseCache: System.MissingMethodException: Method not found: 'Void libcmake.CMakeParameters..ctor(System.String, System.String, libcmake.CMakeConfiguration)'. at libcmake.Linux.RemoteCMakeParameters..ctor(String daemonDirectory, String cmakeListsDirectory, Func`1 remoteSourceFilesDirectoryResolver, Func`1 remoteCMakeListsTxtDirectoryResolver, CMakeConfiguration config) at Microsoft.VisualStudio.CMake.Linux.Project.RemoteCMakeParserProvider.GetCMakeParameters(String cmakeListsFileOrDirectory, CMakeWorkspaceConfiguration cmakeConfiguration, String workspaceDirectory) at Microsoft.VisualStudio.CMake.Project.Utils.<GetCMakeParametersAsync>d__35.MoveNext() End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.CMake.Project.ExternalBuildProject.ProjectProvider.<ParseProjectAsync>d__46.MoveNext() End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.VisualStudio.CMake.Project.ExternalBuildProject.ProjectProvider.<ParseProjectAsync>d__46.MoveNext() End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.ParseCache.<ParseAsyncImpl>d__34.MoveNext() 10:26:15.5939244 [Info, Thread 47] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.Services.BuildProjectScannerService: Scanner Parsing done: projectfilepath CMakeLists.txt Config Name:linux-debug, took 51ms. 10:26:15.5939244 [Info, Thread 47] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.Services.BuildProjectScannerService: Compute file data values for CMakeLists.txt Config linux-debug 10:26:15.5939244 [Error, Thread 47] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.Services.BuildProjectScannerService: FDV Error for CMakeLists.txt Config linux-debug Canceled False AutoGenerateCanceled False 10:26:15.5988930 [Info, Thread 6] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.Services.BuildProjectScannerService: OnFileScannerCompleted for CMakeLists.txt 10:26:15.5988930 [Info, Thread 15] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.Services.BuildProjectScannerService: Finishing scan.
已尝试的解决方法:
- 删除并重建cmake缓存
- 调整cmake预设
- 遵循微软WSL2编译Linux的相关指南
内容的提问来源于stack exchange,提问作者Ken Cummins
相关产品推荐
相关产品推荐

