Setup VS Code with C++ On Windows 11 (or 10)

Поділитися
Вставка
  • Опубліковано 23 січ 2025

КОМЕНТАРІ • 82

  • @kurdonthego
    @kurdonthego Рік тому +6

    Wow, i was stuck on this for a few days after I got a new ssd. A lot of other videos use the source forge mingw which I found didnt work but came across your's and now its working! Super short and right to the point amazing

    • @abc-qk3ml
      @abc-qk3ml 5 місяців тому

      So all that error is because of source forge mingw?

  • @GauravSharma-ct4uc
    @GauravSharma-ct4uc 10 місяців тому +4

    sir , you are the best , finally I was able to run c++ code in vs code . Thankyou so much sir💯💯

  • @EMC273
    @EMC273 4 місяці тому +2

    great straightforward video on how to set up c++ in vscode video.

  • @shrutiisinhaaa
    @shrutiisinhaaa 4 місяці тому +1

    Thank you sooo much!! this was very helpful

  • @OtakuTube636
    @OtakuTube636 Рік тому +2

    thankyou brother best video got it alright working like champ💖💝

  • @wat_abokmog1837
    @wat_abokmog1837 10 місяців тому +1

    Good job, thank you so much 👍🏼✌🏼

  • @komiljonzargarov8112
    @komiljonzargarov8112 Місяць тому

    but I can't do anything with launch.json ,unable to start debugging, Unexpected GDB output from command " - environment-cd .....

  • @mienai955
    @mienai955 3 місяці тому +1

    Thank you so much. This really worked!

    • @KNuggies
      @KNuggies  3 місяці тому

      Glad it helped!

  • @SalaarTariq
    @SalaarTariq 5 місяців тому +3

    The terminal process terminated with exit code: -1.
    It gives me this error. I have reinstalled vs code and followed all of your steps kindly guide me through it.

    • @sulthan7207
      @sulthan7207 25 днів тому

      Did you find any solution for this problem or you decided to move to other platform?

  • @abhikyadav1672
    @abhikyadav1672 Рік тому +2

    i am not getting any output in terminal but the code is compiling successfully what could be the issue ?

    • @KNuggies
      @KNuggies  Рік тому

      I've seen VS Code not display the terminal output for the first run after setting up everything because it's on another tab in the terminal area. However, this was solved for me by manually clicking the terminal tab or just running the program again. Not sure this is what you experienced.

    • @Jxs.911
      @Jxs.911 4 місяці тому

      I'm facing the same problem , also there's another error saying ; cannot open source file "iostream". Please run the 'Select IntelliSense Configuration...' command to locate your system headers.

  • @ScriptoTheCode
    @ScriptoTheCode 8 місяців тому +4

    I'm having an issue where isn't working are there any fixes ?

    • @KNuggies
      @KNuggies  7 місяців тому +1

      Might be using iostream functions without the "std::" in front of each use or not "using namespace std;" would cause problems. If it just can't include iostream, the compiler could be missing core parts of C++ and probably needs reinstalled or some such thing. Hopefully you have it sorted out :)

    • @ScriptoTheCode
      @ScriptoTheCode 7 місяців тому +1

      @@KNuggies I found a step that I did wrong so reinstalling it did end up working so thank you for the help

  • @HamzaShaikh-q7c
    @HamzaShaikh-q7c Місяць тому +2

    I am not getting GDB in VS code, what should I do?

    • @defendchrist
      @defendchrist Місяць тому +1

      SAME @KNuggies please respond

    • @KNuggies
      @KNuggies  Місяць тому

      I have had this issue be one of two things. Either gdb did not install properly or the PATH does not include the directory containing gdb. In the first case, you can try to uninstall/reinstall. In the second case, verify that you have the proper gdb path set on your PATH variable. Hopefully this helps.

    • @KNuggies
      @KNuggies  Місяць тому

      I have had this issue be one of two things. Either gdb did not install properly or the PATH does not include the directory containing gdb. In the first case, you can try to uninstall/reinstall. In the second case, verify that you have the proper gdb path set on your PATH variable. Hopefully this helps.

    • @joaquinraphaelbuidon1058
      @joaquinraphaelbuidon1058 5 днів тому

      @@KNuggies how do you reinstall it?

  • @ml9871234
    @ml9871234 Рік тому +1

    why only take the ...-gdb package? any reason not to just take all?

  • @logisticsmakati442
    @logisticsmakati442 7 місяців тому +2

    the vscode said that my file is does not exist and needs to open json file, how to fix?

    • @KNuggies
      @KNuggies  7 місяців тому

      Not sure what json file it would be trying to open...unless it is prompting you to create the "launch.json" file to save your launch configuration for each time you press F5. That is normal as it will create a "launch.json" file to store which launch mode you chose. If you have an issue with this file, you can delete it from the .vscode directory and try again.

  • @seanhayden7776
    @seanhayden7776 5 місяців тому +1

    I'm getting an error when trying to run the program after hitting F5;
    "The preLaunchTask 'C/C++: gcc.exe build active file' terminated with exit code -1"

    • @imanshaf8429
      @imanshaf8429 4 місяці тому

      I get the exact same thing. Did you solve it?

    • @seanhayden7776
      @seanhayden7776 4 місяці тому

      @@imanshaf8429 nope, gave up and just got a windows laptop lol

    • @KNuggies
      @KNuggies  4 місяці тому

      Thanks for the feedback. I've seen a few comments about this error, but I haven't been able to recreate it.

    • @jarrydoneill7834
      @jarrydoneill7834 3 місяці тому

      @@KNuggies I got this problem, but yet it still shows the output of hello world in the correct way

    • @chips2786
      @chips2786 2 місяці тому +1

      Delete the .vscode folder

  • @Blue-the-broke
    @Blue-the-broke 4 місяці тому +1

    holy shit finally i found something that worked thanks

    • @KNuggies
      @KNuggies  4 місяці тому +1

      Thank you for the feedback! It's always nice to hear that the tutorial is current.

  • @AF-ps1ki
    @AF-ps1ki 7 місяців тому +1

    I don't know why I don't find (Environment variables). This is the second time I'm trying to install the program, but I'm having the same problem.

    • @KNuggies
      @KNuggies  7 місяців тому +1

      Searching the start menu for "Environment" always brings it up for me on Windows 10 or 11.
      Right clicking the start menu and opening "System" then clicking the "Advanced system settings" link gets me there too.
      Hope this helps.

  • @callmejames1010
    @callmejames1010 Місяць тому +1

    i got this error when trying to run using the compiler : main.exe does not exist.
    and it gives option to open "launch.json".
    sorry for uncomplete confirmation

    • @KNuggies
      @KNuggies  Місяць тому

      Not sure what the error is unfortunately. Is more information provided beyond "main.exe"

    • @KNuggies
      @KNuggies  Місяць тому

      When pressing F5 or select the run with debug option, it will use whatever configuration is in the "launch.json" file. If you can delete your current launch.json file in the .vscode directory, you might be able to select the correct compiler and create a new launch.json the next time you try to debug. If no compiler options show up on the first press of F5, then it is likely that the compiler is not on the path. You might want to confirm that "gcc --version" is showing the version as expected. Also, building from the command line with something like "g++ main.cpp" might help confirm that you have the compiler and your code will build.

    • @callmejames1010
      @callmejames1010 Місяць тому

      @@KNuggies so you're suggesting that i delete the current launch.json file from vscode directory, then try to run compiler in vscode again, and this time it will automatically create the right .json file to execute c++ code? or do i have to create it manually?
      the compiler options is available when i press F5, and i've check gcc --version and it run without problem, but just when it comes to run the code c++ it won't.

    • @KNuggies
      @KNuggies  Місяць тому

      After deleting the launch.json file and restarting VS Code, it should prompt you for how to run the code and a allow you to generate a new launch.json in the debug tab on left if you find launch settings you want to use every time.

  • @СтепанПерфильев-ы5к
    @СтепанПерфильев-ы5к 5 місяців тому +2

    thank you very much !!!

  • @kyo911
    @kyo911 9 місяців тому +1

    Thank you very much !

  • @Shinn.h_
    @Shinn.h_ Рік тому +2

    What should i do if i do not have my auto complete working?

    • @KNuggies
      @KNuggies  Рік тому +1

      The main things are installing the programs and adding them to the path in windows. Double check those things first.
      Otherwise, it's such a broad problem, that starting fresh and installing again might be the way.
      Let me know how it goes.

  • @HiroshiHoshigaki
    @HiroshiHoshigaki 11 місяців тому

    hey dude, i dont know why but i cannot see the gcc ane gdb thing in my visual code , the thing which you were doing at 3.50 min help me out here

  • @kinofthestainedblade8370
    @kinofthestainedblade8370 4 місяці тому

    I get the lauch.json file problem after installing everything and following the steps any tips?

  • @kvelez
    @kvelez 6 місяців тому +1

    Good video, do more C++, PHP, C#, Python videos.

  • @alexjimenez6719
    @alexjimenez6719 9 місяців тому +1

    great video

  • @bemnettesfaye3716
    @bemnettesfaye3716 Рік тому +9

    it says something about jason file

    • @kawaiineko6518
      @kawaiineko6518 10 місяців тому +1

      I have the same problem

    • @treyabolicum
      @treyabolicum 9 місяців тому

      @@kawaiineko6518 use g++ main.cpp -o main.exe instead of gcc main.cpp -o main.exe . Additionally make sure you are inside the correct directory, if not make a new folder and use gcc again. Cheers!

    • @BlahMmmBlah
      @BlahMmmBlah 3 місяці тому

      The compiler might need that initial load (like shown in the video with the blue text) to fix that launch.json error.
      Make sure there are no errors in the code when your compiling. Thats what happened with my code. I had an error that was preventing that initial compilation it needed, and it said something like:
      "launch _program_ does not exist vscode"
      Then had a option to open launch.json.
      Once I deleted the error and compiled it for the first time, I saw a whole bunch of blue text in the terminal, and now I don't get the message when I try to run or debug.
      Probably sounds obvious, like no duh an error will prevent a successful compilation, but at least in my case, that's what was causing the json error.😅

  • @phynix6973
    @phynix6973 6 місяців тому +1

    my autocomplete is not working

    • @KNuggies
      @KNuggies  6 місяців тому

      The C++ addon expects to access gcc and gdb (maybe other stuff) on the path.
      If you have everything properly installed and added to the path, you might need to close VS Code and reopen it for the the addon to work it's magic. Otherwise, it's probably an issue with the path or installed installation. Check your path variable and installation location carefully.
      To check your install, you can navigate to "C:\msys64\ucrt64\bin" and "C:\msys64\mingw64\bin" to look around and run commands from the directory. If that's working, the problem is the path.
      There have been times where my Python environment got so messed up, the only way I could fix it was to uninstall VS Code and delete all the local / user files left behind. Then reinstall it fresh. It might be worth a shot if nothing else works.
      Hopefully you were able to get it working.

  • @jsx0328
    @jsx0328 9 місяців тому +1

    Why Msys2?

    • @KNuggies
      @KNuggies  9 місяців тому

      This method was based on the VS Code documentation. I also like using virtual machines, docker containers, WSL, or the original Visual Studio on Windows. There are lots of ways to run C++.

  • @MuhammadAwaisHameed-w5u
    @MuhammadAwaisHameed-w5u 6 місяців тому

    error: failed to init transaction (unable to lock database)
    error: could not lock database: Permission denied my laptop is show this error

  • @KNuggies
    @KNuggies  Рік тому

    Free link to the medium article:
    medium.com/@knuggies/setup-vs-code-with-c-on-windows-a448a439c7b3?source=friends_link&sk=cda21d98ef318f80b9eacdaa1188dc49

  • @leoandrade7461
    @leoandrade7461 3 місяці тому +1

    Please help me, my program at the end gives the error "Unable to start debugging. Unexpected GDB output from command "-environment-cd "C:\\Users\\Léo Andrade\\Documents\\Work". C:\Users\Léo Andrade\Documents\Work: No such file or directory." how can I solve it? I'm about to give up :(

    • @KNuggies
      @KNuggies  3 місяці тому

      Sorry for the delay. Where you able to sort it out or did you run your program some other way? Usually the space in your directory could cause the problem, but it appears that it is already wrapped in quotes. If you haven't tried Docker yet, I'd recommend developing C++ inside a Docker container as a (probably better) alternative to this solution. The VS Code Dev Containers addon makes it pretty easy to get started. If you would like to see a video on this just let me know :)

    • @leoandrade7461
      @leoandrade7461 3 місяці тому +1

      When I run my code I get the message 'open launch.json', I'm already thinking about giving up on this language because it's so difficult to get started in it ¬¬

    • @KNuggies
      @KNuggies  3 місяці тому

      I love C++, but don't use it much any more. What are you trying to do with software? Let that guide you to the language choice. For most people JavaScript or Python are the best choice for a first language due to how useful they are.

  • @MohammadHosseinzadehZavieh
    @MohammadHosseinzadehZavieh 2 місяці тому +1

    Finally I can run c++. The other tutorials are all trashes.

    • @KNuggies
      @KNuggies  2 місяці тому

      Glad it helped! Thanks for watching!

  • @jiyaprasad8989
    @jiyaprasad8989 6 місяців тому +1

    hey...my vscode says it doesn't recognize gcc and gdb....can you please help me?

    • @KNuggies
      @KNuggies  6 місяців тому +1

      If you have everything properly installed and added to the path, you might need to close VS Code and reopen it for the commands to be available. Otherwise, it's not on the path or not installed properly. It's almost always one of theses. Check your path variable and installation location carefully.
      To check your install, you can navigate to "C:\msys64\ucrt64\bin" and "C:\msys64\mingw64\bin" to look around and run commands from the directory. If that's working, the problem is the path.

    • @jiyaprasad8989
      @jiyaprasad8989 6 місяців тому +1

      @@KNuggies in mysys2 too it shows command not found when i type gcc --version and gdb --version

    • @KNuggies
      @KNuggies  6 місяців тому +1

      @@jiyaprasad8989 if you change directory to "C:\msys64\mingw64\bin" (or "C:\msys64\ucrt64\bin") in a terminal and list the files, do you see the gcc or gdb executable? If so, you can run the version check from the current directory with ".\gcc --version" or ".\gdb --version" . If this works, your path variable is the problem. If you don't see the executable files in the bin directory, the installation is the issue.

    • @jiyaprasad8989
      @jiyaprasad8989 6 місяців тому

      @@KNuggies it says open launch.json what to do?