How to Select a .cc File for Debugging in VS2022

Byron Nelson 0 Reputation points
2023-03-29T21:50:49.54+00:00

I have a folder that I had to use a tar command on for a school assignment. All I'm trying to do is debug in Visual Studio 2022. I extracted the folder, and opened it in Visual Studio 2022. There was no Visual Studio project created. After some lengthy trial-and-error sessions, I finally got the CMakeLists.txt files to work correctly and in the Ouput Window it shows what appears to be a successful CMake, as the last line says "CMake generation finished." Now I am trying to debug a file, titled "testcase1.cc". The problem is the Play Button says "Select Startup Item...". When I try to select it from the dropdown menu, it is not there. The only thing there says "Current Document" and it is checked. FYI, I have no executables as far as I know. Please tell me how I can select the file in question and add it to the Debug list.

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,526 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Minxin Yu 10,031 Reputation points Microsoft Vendor
    2023-04-27T06:49:13.9066667+00:00

    Hi,

    Cmd below can be used to create Visual Studio project and build the executables.

    cmake .  -G "Visual Studio 17 2022"
    cmake  --build .
    

    There will be exe and pdb files in Debug folder.

    Then, you can select exe as the startup option, open the .c file in Visual Studio and add breakpoints for debugging.

    Best regards,

    Minxin Yu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments