Debug a C++ project in VS Code

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 ธ.ค. 2024

ความคิดเห็น • 82

  • @yudzu8820
    @yudzu8820 8 หลายเดือนก่อน +57

    vs code with python: 1)click a button 2)enjoy.
    vs code with c++ 1) add configuration file 2) click on something that did not appear. 3) update something that did not even occur 4) frustration 5) sadness 6) there is no point in anything 7) become a farmer

    • @RIPNANI
      @RIPNANI 7 หลายเดือนก่อน

      😂 bruh Im struggling with this mf for a while 😂

    • @Alterx758
      @Alterx758 4 หลายเดือนก่อน

      lol 😂

    • @smorollcancel
      @smorollcancel 4 หลายเดือนก่อน +1

      just wasted my whole day on this bs lmao

  • @michaeldick4900
    @michaeldick4900 3 ปีที่แล้ว +40

    Love VS Code, but this freedom comes at a cost. Some of the things I take for granted in an IDE can be a little bit of a headache, but I love in VS Code you can customize everything! Thank you for this video!

    • @jakubkucera1973
      @jakubkucera1973 ปีที่แล้ว +4

      The next step is setting up neovim, makes you appreciate the user friendliness of vscode ;D

  • @vanity_stars1064
    @vanity_stars1064 3 ปีที่แล้ว +79

    Even Official microsoft is using OSX

  • @munteanionut3993
    @munteanionut3993 2 ปีที่แล้ว +8

    I cannot see g++-7 at 0:37... how to solve that?

  • @andrewstone9931
    @andrewstone9931 3 ปีที่แล้ว +27

    this is years overdue 😂 I remember in my first year of uni thinking it was ridiculously more complicated to set up a build env in vscode than VS2017

  • @Smurdy1
    @Smurdy1 7 หลายเดือนก่อน +4

    Love this video, it did absolutely nothing and not a single thing in the video worked the same in vscode. Making that intellij subscription seem really promising...

  • @wetbadger2174
    @wetbadger2174 3 ปีที่แล้ว +30

    It doesn't give me the option to choose a debugger environment. I can only choose between (gdb) Attach or (gdb) Launch configurations. Neither works.

    • @jigz3903
      @jigz3903 3 ปีที่แล้ว +4

      choose gdb launch
      and do this .. worked for me ----
      paste this whole in the launch.json file
      ==========================================
      {
      // Use IntelliSense to learn about possible attributes.
      // Hover to view descriptions of existing attributes.
      // For more information, visit: go.microsoft.com/fwlink/?linkid=830387
      "version": "0.2.0",
      "configurations": [
      {
      "name": "(gdb) Launch",
      "type": "cppdbg",
      "request": "launch",
      "program": "${fileDirname}/${fileBasenameNoExtension}",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${workspaceFolder}",
      "environment": [],
      "externalConsole": false,
      "MIMode": "gdb",
      // "miDebuggerPath": "C/C++ : g++",
      "setupCommands": [
      {
      "description": "Enable pretty-printing for gdb",
      "text": "-enable-pretty-printing",
      "ignoreFailures": true
      }
      ]
      }




      ]
      }

    • @kamalmohamed6611
      @kamalmohamed6611 3 ปีที่แล้ว

      @@jigz3903 thanks dude how did you write this

    • @jigz3903
      @jigz3903 3 ปีที่แล้ว

      @@kamalmohamed6611 😁 no problem

    • @nexolec109
      @nexolec109 2 ปีที่แล้ว

      @@jigz3903 THANKS JIGZ i really appreciate it u just saved me an enormous headache

    • @Waffle4569
      @Waffle4569 4 หลายเดือนก่อน +1

      ​@@jigz3903 Your comment is hidden?!

  • @techdotsquirrel
    @techdotsquirrel ปีที่แล้ว +1

    Following the steps:
    I keep getting the following errors on Debug Console "Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
    ERROR: Unable to start debugging. Unexpected LLDB output from command "-exec-run". Command 'exec-run'. Invalid process during debug session
    The program '/Users/maxwelljin/GitHub/practiceVSCode/CPP/Main' has exited with code 42 (0x0000002a)."
    what I am missing here?

  • @shashankkr1008
    @shashankkr1008 3 ปีที่แล้ว +5

    Thank you soo much!
    This tutorial was really helpful, now I love debugging and can understand how exactly the code is running.

  • @snehel1586
    @snehel1586 2 ปีที่แล้ว +4

    there should be a way to debug while taking user inputs, while smaller inputs doesn't need a debugger tool bt it's impossible to hardcode huge inputs again and again.

    • @herohera3497
      @herohera3497 11 หลายเดือนก่อน

      cant we give input while debugging??

    • @Brad-qw1te
      @Brad-qw1te 6 หลายเดือนก่อน

      @@herohera3497 there is a way for sure. Just ask chat gpt

    • @aayushshrivastav7515
      @aayushshrivastav7515 หลายเดือนก่อน

      use a file to provide stdin

  • @omranshahrour7291
    @omranshahrour7291 3 ปีที่แล้ว +7

    Doesn't match on windows

  • @chak-pongchung8463
    @chak-pongchung8463 3 ปีที่แล้ว +1

    how can I enable debugging when I am using miniconda for package dependencies? I find passing the following arguments in clion cmake argument works, but VSCode cannot allow me to do that:
    ``` -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS_DEBUG="-O0" -DCMAKE_CXX_FLAGS_DEBUG="-O0"```

  • @kuby6838
    @kuby6838 ปีที่แล้ว +2

    Hi is it normal if i don't get any configuration when i try to debug ? like i'm doing everyting from the video but my launch.json is empty
    Thanks in advance and have a good one

    • @mistahswick4065
      @mistahswick4065 ปีที่แล้ว +1

      did you ever find an answer to this? i have the same problem switching from vs to vs code

  • @kalelalves
    @kalelalves 3 ปีที่แล้ว +3

    Sadly, auto-complete doesn't work on debug console. :/

  • @Paivren
    @Paivren 2 ปีที่แล้ว +3

    "launch.json lives in your worspace directory's workspace folder"
    No, it does not. I only have settings.json and tasks.json.
    this is so frustrating

    • @na_co1165
      @na_co1165 9 หลายเดือนก่อน

      Did u solve it

  • @UTRG-UnderTheRain
    @UTRG-UnderTheRain 2 ปีที่แล้ว

    This is one of the best videos I've seen on this but alas it still won't work on my install lol back to code blocks

  • @salman8562
    @salman8562 3 ปีที่แล้ว +3

    What if I have a multiple-directory c++ program?
    I cannot compile it neither can debug it, but I have a makefile that works just fine. please help me anyone reading this comment, I am in immeasurable pain and my day is ruined.

  • @na_co1165
    @na_co1165 9 หลายเดือนก่อน +1

    I keep getting : launch program does not exist debug, using linux redhat, and gcc as compiler

    • @brs2158
      @brs2158 9 หลายเดือนก่อน

      in task.json, configure "args": [ "-g", "Program1.cpp", "main.cpp", "-o" "${fileDirName}\\${fileBasenameNoExtension}.exe"], since default is empty not eligible to link files and mostly end up with undefined reference error or cannot find .exe file. Hope this works

  • @NilsKubler
    @NilsKubler ปีที่แล้ว

    is it possible to attach to running processes in vs code?

  • @Sacknase381
    @Sacknase381 2 ปีที่แล้ว

    those arent there for me anymore. After i installed the jdk i cant find any c++ debuggers

  • @loraalaq
    @loraalaq หลายเดือนก่อน

    It's not working for me.

  • @prabhavagrawal1712
    @prabhavagrawal1712 2 ปีที่แล้ว +4

    Loved how integratedconsole error is being hidden in this presentation 😂

  • @galibmahim9544
    @galibmahim9544 ปีที่แล้ว +1

    There is a problem I faced,
    "externalConsole": false, then I can't give input to the program at runtime, the debugging session, gets stuck on scanf() or cin and says that, they are running but it the terminal it don't take any input.
    So, It is necessary to "externalConsole": true, to be in the launch.jason file. Then it will open a new terminal and wait for you to give your inputs to the programs when necessary.
    SUGGESSTION: It would be very nice, if this things can be automated by the VSCODE

    • @talentotech-p1e
      @talentotech-p1e ปีที่แล้ว

      did you find a way to use the internal console of vsc for inputs? I'm struggiling with that and I'm thinking it might be related to lldb debugger but might be wrong.

    • @deadeye8
      @deadeye8 ปีที่แล้ว

      ​@@talentotech-p1edont know but this happens with me when i use Windows(launch) config, as soon as i move to gdb launch the input works fine, through internal console.

  • @glaucoa.9214
    @glaucoa.9214 2 ปีที่แล้ว

    I installed gdb and gcc on my MACOS, I do these steps and I can't debug. What do I do?

  • @zXjimmiXz1337
    @zXjimmiXz1337 3 ปีที่แล้ว

    Is it possible to change the formatting of the printed messages? All my output starts with @" and shows the new-line characters
    ... How can I just show the plain output?

    • @Dinesh45444
      @Dinesh45444 ปีที่แล้ว

      change the line ending from LF to CRLF or plain text
      you can see in the video bottom right status bar the blue one it show line ending is set to LF change it.

  • @tanmaykumar9277
    @tanmaykumar9277 2 ปีที่แล้ว

    What if we want to input a value using cin? we can't write anything in debug console

  • @rjeejacobjacob
    @rjeejacobjacob ปีที่แล้ว

    Suppose I don't have the .cpp source file but only the binary "a.out", which is already running. Is there a way for me to monitor the variables and expressions after attaching the debugger to the a.out process?

    • @codecoderr7495
      @codecoderr7495 ปีที่แล้ว

      you'd need the debug symbols to exist in the executable (GCC debug symbols added to compiler), and a GDB stub (Server) running in that app.
      Then GDB Client (say for ARM GCC: arm-none-eabi-gdb). Then connect through IP address & port from GDB Client into GDB stub.
      And then in the GDB stub implementation, you'd need a debug stack of sorts to extract the registers and paste them there. So GDB client could watch immediate register as variables and expressions real time.

  • @avishcheetaram1807
    @avishcheetaram1807 ปีที่แล้ว

    How do I input variable values during debugging mode?

  • @zXjimmiXz1337
    @zXjimmiXz1337 3 ปีที่แล้ว

    Didn't get a response previously - how can I remove the @ characters and the newline characters from every print statement? Makes the formatting of all our logging completely illegible making debugging 10X harder!

    • @Dinesh45444
      @Dinesh45444 ปีที่แล้ว

      change your line ending to CRLF

  • @mmkvhornet7522
    @mmkvhornet7522 2 ปีที่แล้ว

    hi your steps work fine but i need to reconfigure each time !!! yes each time why please answer me 🙏🙏

  • @VanFS3K
    @VanFS3K 2 ปีที่แล้ว +2

    There is no selection of debugger environment. These setup instructions are obsolete. Does anyone have an updated one?

    • @Manas-jj6xf
      @Manas-jj6xf 4 หลายเดือนก่อน

      Did you find a workaround?

  • @ΓιάννηςΝάκας-ι4υ
    @ΓιάννηςΝάκας-ι4υ 2 ปีที่แล้ว

    It says that it was built succesfully but then it says "Unable to start debbuging. The value of miDebuugerPath is valid. What should I do? I did exactly what you did on the video.

    • @Dinesh45444
      @Dinesh45444 ปีที่แล้ว

      set miDebuggerPath to exact path where your gdb.exe is present

  • @ruscyber9765
    @ruscyber9765 2 ปีที่แล้ว +1

    My debugger starts and turns off after on its own

  • @iamyouu
    @iamyouu 2 ปีที่แล้ว

    How to do this on Linux

  • @Waffle4569
    @Waffle4569 4 หลายเดือนก่อน +1

    I love how this tutorial straight up doesn't work in 2024. They already broke half the stuff in here

  • @r2com641
    @r2com641 3 ปีที่แล้ว

    but this would be inferior to debugger offered by MSVC isnt it?

  • @FrankMadero
    @FrankMadero 2 ปีที่แล้ว

    Where is the memory view and register view? Not a very good tool for serious debugging.

    • @codecoderr7495
      @codecoderr7495 ปีที่แล้ว

      if you're programming C++ games you don't need these at all.
      you'd only need them if you're coding emulators in baremetal hardware, which makes no sense at all since you should be using a debug unit on said units.

  • @SMGGamerzOfficial
    @SMGGamerzOfficial 3 ปีที่แล้ว +1

    Will you make a video in which we could make a normal game in visual studio code c++

  • @xth3x
    @xth3x 4 หลายเดือนก่อน

    if you didnt install the debugger when installing the g++ compiler, then open the MSYS2 terminal and run the command
    pacman -S mingw-w64-x86_64-gdb
    to install gdb
    NOTE: path is not the same as compiler add "C:\msys64\mingw64\bin" to your local paths
    Follow the rest of the steps in the video and it should work

  • @Weeeeeeeeeeeeeah
    @Weeeeeeeeeeeeeah ปีที่แล้ว

    Why to make a tutorial on a microsft software, microsoft uses a mac? 😕

  • @benjaminbencik8498
    @benjaminbencik8498 3 ปีที่แล้ว +1

    This was helpful, thanks:)

  • @icopypasta
    @icopypasta 3 ปีที่แล้ว

    Very helpful, thank you much!

  • @gauravrewaliya3269
    @gauravrewaliya3269 3 ปีที่แล้ว +2

    there is no input console

    • @gauravrewaliya3269
      @gauravrewaliya3269 3 ปีที่แล้ว +3

      just set externalconsole =true it works fine now

  • @charsetUTF-8
    @charsetUTF-8 3 ปีที่แล้ว

    how to show string debugging, i use WinOS

  • @nancygaur6705
    @nancygaur6705 3 ปีที่แล้ว

    Sir can you please solve this error in vs code "this language server has crashed 5 times in 3 minutes. It can be restarted." Fix it

  • @callofgamingcog8992
    @callofgamingcog8992 2 ปีที่แล้ว +2

    Not them using an Apple's OS. >_

  • @themujahed
    @themujahed 2 ปีที่แล้ว

    microsoft product using in a apple product

  • @MrTomro
    @MrTomro 3 ปีที่แล้ว

    love it, super simple

  • @10bokaj
    @10bokaj 4 หลายเดือนก่อน

    ok, so microsoft uses mac OS...

  • @l1nker_zyoutubetm611
    @l1nker_zyoutubetm611 2 ปีที่แล้ว

    Нечем не помогла...

  • @Kifri_filosofia
    @Kifri_filosofia ปีที่แล้ว +1

    visual studio code is bullshit, It is literally impossible to nnot get an error

  • @gammyhorse
    @gammyhorse 2 ปีที่แล้ว +3

    Visual Studio Code sucks big time.