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

如何在Visual Studio 2019 CMake项目中同时调试多个可执行文件?

How to Debug Multiple Executables (Server/Client) in Visual Studio 2019 CMake Project

Hey there, I’ve dealt with this exact setup before—here’s how to get VS2019 to launch both your server (exec1) and client (exec2) for simultaneous debugging:

  • First, make sure the Solution node is visible in the Solution Explorer. If it’s hidden, go to View > Solution Explorer to bring it up.
  • Right-click the root Solution node (not individual CMake targets) and select Properties from the context menu.
  • In the Properties window, navigate to Common Properties > Startup Project in the left sidebar.
  • Switch the radio button from Single startup project to Multiple startup projects.
  • In the list below, locate both exec1 and exec2. For each, set their Action dropdown to Start. You can drag and reorder them if you need one to launch before the other (e.g., server first).
  • Click OK to save your changes.

Bonus: Customize Debug Settings for Each Executable

If you need to pass command-line arguments or tweak debug configurations for either program:

  • Right-click the target (like exec1) in the Solution Explorer under CMake targets.
  • Select Debug and Launch Settings—this will open a launch.vs.json file.
  • You can add args or adjust settings for each target here. For example:
{
  "configurations": [
    {
      "name": "exec1",
      "project": "CMakeLists.txt",
      "projectTarget": "exec1.exe",
      "args": ["--port", "8080"]
    },
    {
      "name": "exec2",
      "project": "CMakeLists.txt",
      "projectTarget": "exec2.exe",
      "args": ["--server", "localhost"]
    }
  ]
}

Once everything’s set up, hit the green Debug button—both your server and client will launch in separate debug sessions, and you can set breakpoints, inspect variables, and step through code in either one just like normal.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.14 08:46:02