VS2022通过WSL2交叉编译失败(libcmake错误?)

Ken*_*ins 1 cmake cross-compiling wsl-2 visual-studio-2022

我正在尝试将一个相当简单的 C++ 项目编译为 ELF 格式以进行容器化,并且实际上它可以短暂工作,但是现在,当我尝试通过 WSL2 构建任何 C++ 代码时,它在 CMake 阶段失败,甚至在它可以之前自行配置。我已经卸载并重新安装了 VS 2022 17.4,甚至回滚了昨天的最新 Windows 11 更新,以防万一,但我仍然收到相同的错误,表明 cmake 库未正确加载(尽管我什至安装了我的 WSL 环境中的 MS 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.
Run Code Online (Sandbox Code Playgroud)

我尝试删除和重建 cmake 缓存,调整 cmake 预设,按照 MS 说明使用 WSL2 为 Linux 进行编译,但它再也不起作用了。

Ken*_*ins 5

在 MS 站点上探索了足够长的时间后,一个答案从灌木丛后面匆匆跑了出来……

VS 17.4 更新 (11/30/2022) 终止了 cmake/wsl 集成。所以,在他们解决这个问题之前,我将尝试卸载并重新安装 17.2

https://developercommunity.visualstudio.com/t/CMake-Project-stopped-working-on-WSL-aft/10216023