Deploy, run, and debug your Linux MSBuild C++ project in Visual Studio

Deploy, run, and debug your Linux MSBuild C++ project in Visual Studio
  • Article
  • 7 minutes to check out

Linux assistance is offered in Visual Studio 2017 and later on. To see the documents for these variations, set the Version drop-down situated above the tabulation to Visual Studio 2017 or Visual Studio 2019

Once you’ve developed a MSBuild-based Linux C++ task in Visual Studio and you’ve linked to the job utilizing the Linux Connection Manager, you can run and debug the job. You assemble, carry out, and debug the code on the remote target.

Visual Studio 2019 variation 16.1 and later on: You can target various Linux systems for debugging and structure. You can cross-compile on x64 and release to an ARM gadget when targeting IoT situations. To learn more, see Specify various devices for structure and debugging later on in this post.

There are numerous methods to connect with and debug your Linux job.

  • Debug utilizing standard Visual Studio functions, such as breakpoints, view windows, and hovering over a variable. Utilizing these techniques, you might debug as you generally would for other task types.
  • View output from the target computer system in the Linux Console window. You can likewise utilize the console to send out input to the target computer system.

Debug your Linux task

  1. Select debugging mode in the Debugging residential or commercial property page.
    GDB is utilized to debug applications working on Linux. When debugging on a remote system (not WSL) GDB can run in 2 various modes, which can be chosen from the Debugging Mode choice in the task’s Debugging home page:

    vs2019 debugger settings Debugging chosen and Debugging Mode highlighted with G D B chosen and highlighted from the dropdown list.” data-linktype=” relative-path” >

    GDB is utilized to debug applications working on Linux. GDB can run in 2 various modes, which can be chosen from the Debugging Mode choice in the task’s Debugging residential or commercial property page:

    vs2017 debugger settings Debugging chosen and Debugging Mode highlighted with G D B chosen and highlighted from the dropdown list.” data-linktype=” relative-path” >

    • In gdbserver mode, GDB is run in your area, which links to gdbserver on the remote system.
    • In gdb mode, the Visual Studio debugger drives GDB on the remote system. This is a much better choice if the regional variation of GDB isn’t suitable with the variation set up on the target computer system. This is the only mode that the Linux Console window supports.
    Note

    If you are not able to strike breakpoints in gdbserver debugging mode, attempt gdb mode. gdb should initially be set up on the remote target.

  2. Select the remote target utilizing the requirement Debug toolbar in Visual Studio.

    When the remote target is readily available, you’ll see it noted by either name or IP address.

    Screenshot showing a Remote target IP address.

    If you have not linked to the remote target yet, you’ll see a direction to utilize Linux Connection Manager to link to the remote target.

    Screenshot showing the Remote Architecture, which is x64.

  3. Set a breakpoint by clicking in the left seamless gutter of some code that you understand will carry out.

    A red dot appears on the line of code where you set the breakpoint.

  4. Press F5(or Debug > Start Debugging) to begin debugging.

    When you begin debugging, the application is put together on the remote target prior to it begins. Any collection mistakes will appear in the Error List window.

    If there are no mistakes, the app will begin and the debugger will stop briefly at the breakpoint.

    Screenshot showing the app has hit a breakpoint.

    Now, you can connect with the application in its existing state, view variables, and action through code by pushing command secrets such as F10 or F11

Like this post? Please share to your friends:
Leave a Reply

;-) :| :x :twisted: :smile: :shock: :sad: :roll: :razz: :oops: :o :mrgreen: :lol: :idea: :grin: :evil: :cry: :cool: :arrow: :???: :?: :!: