How to set up C++ in Visual Studio Code

Поділитися
Вставка
  • Опубліковано 12 жов 2023
  • How to set up C++ with Visual Studio Code (vscode).
    Install Visual Studio Code: code.visualstudio.com/
    Install minGW (C++ Compiler): code.visualstudio.com/docs/cp...
    Steps to setup minGW in windows:
    1. Install MSYS2 using the link provided by microsoft github.com/msys2/msys2-instal...
    2. Open MSYS2, enter the follow command:
    pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain
    3. Hit Enter for default selection, then type Y and hit Enter to proceed with the installation.
    4. In your search bar, look for edit Environment Variables and open the setting. In the window bottom right, click Environment Variables. Click on Path in your list of User Variables. Click edit, new, add the following:
    C:\msys64\ucrt64\bin
    5. In your seach bar, look for Command Prompt and open it. Type in gcc --version, g++ --version, and gdb -- version. You should see minGW setup correctly.
    Open vscode, and in extensions, look for C/C++ Extension Pack and install it. Then, create a new text file. Name it whatever you want, but be sure to include the .cpp extension.
    Ex) Create a file named test.cpp and add some starter code. (include iostream, using namespace std, int main() ... cout "Hello World!")
    On the top right, click on the play button to run your program. Select Run C/C++ File. You should now see your output display in the built-in terminal of VS Code!
    And, there you have it! How to setup C++ for Visual Studio Code!
    C++ Programming Playlist:
    • C++ Programming Tutorial
    Java Game Programming Projects Playlist:
    • Java Game Programming ...
    JavaScript Game Programming Projects Playlist:
    • JavaScript Game Progra...
    Subscribe for more coding tutorials 😄!

КОМЕНТАРІ • 483

  • @fardinkhandaker3436
    @fardinkhandaker3436 2 місяці тому +8

    I've been looking for a video like this. I always struggle to compile but now, it's not a problem. Thank you!

  • @ziprock
    @ziprock 5 місяців тому +39

    i tried getting a compiler to work with vs code last year and couldn't figure it out and gave up. this method was super easy, straight to the point, and ive got a working compiler now thank you.

    • @shuaibakhtar5333
      @shuaibakhtar5333 26 днів тому +1

      brother, my compiler is still not working properly could you please help me

  • @theironrhino110
    @theironrhino110 3 місяці тому +4

    Thanks a lot for the helpful guide! I know the steps are explained on the website but having someone to walk you through the process is a lot less stressful!

  • @Dulkage
    @Dulkage 7 місяців тому +33

    The only tutorial that actually worked for me! Thank you!!

    • @thabomaleke874
      @thabomaleke874 21 день тому

      The other ones 😞. They are really useless

    • @Dulkage
      @Dulkage 21 день тому

      @@thabomaleke874 Yea

  • @alexwade9888
    @alexwade9888 4 місяці тому +53

    The only video I could find that actually explained this clearly. Subscribed just off the quality of this video alone. As soon as I have hello worlded I'll be back to see what else you've got.

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

      same here! all possibilities ! really well explained, well done man!!!

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

    incredibly greatful for such a nice simple put tutorial!!! Very straight to the point! love it, thanks a ton:D

  • @user-nc6ki5ts7x
    @user-nc6ki5ts7x 3 місяці тому +6

    Thank you. My cmd line test didnt work at 3:57 but it worked in the MYSYS2 cmd line. This solved my issue with not having a compiler.

  • @andrewbauman256
    @andrewbauman256 5 місяців тому +57

    Hey everyone if g++ or the other compilers aren't showing up at 06:08 time in the video or when you try to run the code (which is what happened to me every single time I tried this) this sounds so dumb but just make sure you did all the previous steps correct and RESTART YOUR COMPUTER. It worked for me after this. Thanks Kenny Yip Coding for the tutorial and happy coding y'all :)

    • @user-di8hh2pc4d
      @user-di8hh2pc4d 4 місяці тому +6

      my problem right here, life saver

    • @natepotate5025
      @natepotate5025 3 місяці тому +2

      ive been trying to fix this problem all day when all i had to do was restart my computer, thank you

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

      your a life saver, its 5:35am and im so tired of trying to get this thing to work

    • @hime-kamisama
      @hime-kamisama 3 місяці тому +1

      You actually only need to close all VSCode windows so that the Path changes take effect.

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

      Is there an error like this
      The preLaunchTask 'C/C++:gcc.exe build active file' terminated with exit code -1 ?

  • @user-kc1gp5mo7k
    @user-kc1gp5mo7k 6 місяців тому +13

    Thanks very much. You really helped me a lot.
    Very simple and straight-to-the-point video.
    Thanks a lot once again.😊

  • @taongaphiri6084
    @taongaphiri6084 7 місяців тому +174

    This never works for me. It's like the world doesn't want me using vs code for c++, I followed this tutorial step by step, watched the video three times, and it still failed.

    • @KennyYipCoding
      @KennyYipCoding  7 місяців тому +15

      Which step are you failing at?

    • @farisraid7588
      @farisraid7588 7 місяців тому +20

      @@KennyYipCoding last step is just not working something is wrong with the compiler or something i have no clue this is my 3rd vid so far

    • @zombz4291
      @zombz4291 7 місяців тому +37

      @@KennyYipCoding same, when i run there's no "C/C++ :g++.exe build and debug active file"

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

      ​@@KennyYipCoding yeah me too i try that for three times

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

      @@farisraid7588 Try restarting vs studio

  • @user-hx6xd7of4u
    @user-hx6xd7of4u 4 місяці тому +1

    This is so well-made, thank you!!
    Subscribed, keep up the good work

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

    Thank you very much for uploading this to the point tutorial! I could get cpp running in one go :)

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

    I watched so many tutorials but this one worked thanks 😊😊

  • @Bruh-py5hk
    @Bruh-py5hk 3 місяці тому +1

    Thank you, I've been using online gdb for the longest, but just having the choice of vs code makes me happy. Make sure to restart the computer afterwards as well since it wasn't working until after.

  • @zicraftian
    @zicraftian 6 місяців тому +3

    helpful and to-the-point thanks for this!

  • @user-ey6op6qb1j
    @user-ey6op6qb1j 4 місяці тому +1

    the best video i have ever watched . you explained this in detail and clearly thank you.

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

    You dude is a hero! Let me add that the first time you run your code after you do this, there'll be a bunch of errors. Depending on how fast your computer is, it will take time before all the scripts load up and be read in your computer's system. Mine had a bunch of error at first when I ran my codes and I just restarted my laptop and it eventually worked.

  • @kasulejoseph9317
    @kasulejoseph9317 26 днів тому

    After 3 attempts, it worked out. Thanks for sharing

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

    Thankyou so much !! you've made it easier for me.

  • @HARIPRIYASRIPERAMBUDURU
    @HARIPRIYASRIPERAMBUDURU 11 днів тому

    I done installation within few minutes.I've been looking for a video like this.thanks a lot!!

  • @kennethumis6907
    @kennethumis6907 5 місяців тому

    I think you are a teacher. Life made easy. Thanks.

  • @fenrisfish2800
    @fenrisfish2800 5 місяців тому +2

    Fantastic tutorial, was searching through a few videos to get started on c++ and this one was the best

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

    Perfectly running after your tutorial thanks.

  • @SiennaOfGalois
    @SiennaOfGalois 27 днів тому

    Such a helpful tutorial 👏 !!! I had initially installed an up-to-date msvc for my vscode as instructed but for whatever reason the compiler version would always default to 199707 (c++98) despite all the online tutorials I followed elsewhere and efforts I made trying to fix it. However, completely switching to minGW was amazing as everything got fixed and now my c++23 code runs flawlessly!

  • @justaguy1321
    @justaguy1321 20 днів тому

    Thank you my friend, helped alot. All the best! 🙏

  • @rosesarered397
    @rosesarered397 5 місяців тому

    Thanks! This was very helpful for me.

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

    You saved me after 4 hrs of trying to run my code and facing problems thanks 😂

  • @DivijMahajan-uc2uy
    @DivijMahajan-uc2uy 2 місяці тому

    Worked in my case finally I am using vs code thankyou bro.

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

    Thank you so much! Very Helpful!

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

    It worked for me. Thanks :)

  • @awenixmusic
    @awenixmusic 7 місяців тому +47

    3:40 - For those who get the error "gcc is not recognized as an internal or external command", close the terminal and open the command prompt again but run as administrator.

    • @RamirezAnaMonicaS
      @RamirezAnaMonicaS 7 місяців тому +3

      it still doesn't work

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

      it is just not working
      the only step where i am having issue is while doing that download in mysys2 as only 7 downloads turned successful out of 63

    • @vinamrajeet
      @vinamrajeet 6 місяців тому +19

      Instead of pasting it on path of user variable, paste it on path of system variable

    • @user-kd4xu8eh5p
      @user-kd4xu8eh5p 6 місяців тому

      thank you it worked after doing as u said@@vinamrajeet

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

      THIS WORKED TYSM

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

    thanks men i really appreciate u giving such a detailed explanation video

  • @abdou2523
    @abdou2523 5 місяців тому

    I was so frustrated my code that worked perfectly fine in uni wouldn't work on my pc this is all I needed thank you

  • @atharvpal7038
    @atharvpal7038 5 місяців тому

    Thanks man! Great video!

  • @RanaAhmed-el6wm
    @RanaAhmed-el6wm 2 місяці тому

    i can not even how I can thank you I got four hours trying to turn it on and I didn't know really really thank you .🥰🥰🥰💗💗💗

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

    such a great and helpful video ! Thank you very much :)

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

    Thank you so much! You saved my life 😁

  • @shubhamupadhyay3174
    @shubhamupadhyay3174 8 місяців тому +1

    Thank you for your work

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

    Very well explained. Thank you for this wonderful video :)

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

    Thnaks a lot Buddy that was a 10/10 helped me 1000%

  • @user-zf1er6ps9o
    @user-zf1er6ps9o 4 місяці тому

    Thx u Kenny! All Done!

  • @armanforouharfard2490
    @armanforouharfard2490 Місяць тому +2

    Hello Kenny, thanks for your video, i'm having a problem when i want to run my codes whenever i want to run it, it sends me into my terminal's output section and says "'scriptcs' is not recognized as an internal or external command, operable program or batch file." can you help with this?

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

    You are such a goat for this thank you 🙏

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

    It really worked for me.
    Thanks 🙏 i have gone through many tutorials but this one only this worked❤

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

    it's not working from the very first line with "#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (D:\Other\theSigame
    andom stuff\Valorant-TriggerBot-main\val trigger\val_trigger\vt\tests.cpp).C/C++(1696)"

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

    Appreciate the help.

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

    THANK YOU, it finnaly works.

  • @KonnarakYahath
    @KonnarakYahath 6 днів тому

    Thank for this helpful video❤

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

    Great and quick tutorial!

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

    Your tutorial is great, it realy helped me. 😀

  • @andresmorales5807
    @andresmorales5807 4 місяці тому +3

    I get an error that says: "cl.exe build and debug is only usable when VS Code is run from the Developer Command Prompt for VS."

  • @ahmedhassan5783
    @ahmedhassan5783 8 місяців тому

    can you make a video for setting up C# in vscode? i had a problem with it requiring some sort of a subscription to the C# development kit extension

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

    thank you so much... very clear tutorial..

  • @azumichaser5824
    @azumichaser5824 5 місяців тому +2

    it shows cl.exe build and debug is only usable when VS Code is run from the Developer Command Prompt for VS. when i run the code, can someone help me?

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

    I have one problem with VSCODE. When i run the code, an error appears "performing the preliminary task "C/C++: gcc.exe the build of the active file is " completed with exit code -1". in the "problems" is written package.json / You should not use the "*" activation, as it affects performance. How to solve this problem?

  • @douglasfox1522
    @douglasfox1522 5 місяців тому

    The only tutorial that has actually worked! Thank you so much

  • @study.ansh7405
    @study.ansh7405 10 днів тому

    thanku so much for the guide..it really helped! Also is there anyway to permanently select the compiler until we want? i mean it always asks to select the compiler every time u run the code (like u shown at the end of vid)...any solution for that?

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

    As someone who is a complete beginner, THIS IS THE MOST USEFUL VIDEO I HAVE EVER COME ACROSS, THE ONLY VIDEO THAT HELPED. Thankyou so much honestly. 🔥

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

    The best so far...ty

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

    thank you very much , I have subscribed to your channel

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

    Thank you so much man

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

    is that any way to hide that long blue colored line before the actual output?

  • @realjihadi7107
    @realjihadi7107 5 місяців тому

    i surfed many videos and finally found this

  • @markuchi4756
    @markuchi4756 3 місяці тому +11

    Hi I have a question, so I followed ur vid and tried the part where I run the build and run the hello world code, when I ran the code an error appeared saying launch: program 'C:\C++\test.exe' does not exist. How do I fix this?

    • @Nourita_at...
      @Nourita_at... 3 місяці тому +2

      Me too the same problem ! , i tried a right clik and run code it work perfectly 👌🏽 , but when i try his method to run the code it happen the same problem i don't know why 🤷🏼‍♀️
      Any way 😅 the code works perfectly when i made Ctrl+Alt+N

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

      I had the same issue but apparently the problem is that when running the program I was choosing C/C++:gcc.exe instead of C/C++:g++.exe

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

      @@sofiaholguinjimenez5657 thanks bud this worked for me too, though the first time i ran it my antivirus detected it as a trojan lol.

  • @user-su2jd7pm6j
    @user-su2jd7pm6j 4 місяці тому

    Thank you very much, good luck.

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

    Thank you so much it works for me

  • @cofishachou
    @cofishachou 13 годин тому

    Life saver man

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

    Bro i done everything right but when i run code it’s telling me ( unable to find executable for (my username) can you help me what i need to do ?)

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

    thank you! Do you have a tutorial to be able to compile C++20.? your instructions are easy to follow, ty! appreciate your videos!

  • @fedaasalah7557
    @fedaasalah7557 5 місяців тому

    thanks it was really helpful

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

    Easy and simple. New sub

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

    I am tryna install MYSYS oon my windows bu this what it is giving me : You have selected an existing, non-empty directory for installation.
    Note that it will be completely wiped on uninstallation of this application.
    It is not advisable to install into this directory as installation might fail.
    Do you want to continue?

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

    I have tried it three times ...it is always failing at installing mys2 in that prompt.. it showing error in every gile after extracting that 58 files

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

    At first I thought It didn't even after doing the steps correctly but the problem that I was encountering was at 06:08 the complilers rather than clicking the one with g++ I was instead clicking cpp.exe thanks for the help this almost took 1 week to figure out

  • @gokulanand.xl-a1lcmm367
    @gokulanand.xl-a1lcmm367 2 місяці тому +1

    In final step,Instead of c/c++ g++ debug, i have c/c++ gcc . I dont know how to change ??

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

    Thank you so mcuh!

  • @OscarT-vz5hx
    @OscarT-vz5hx 7 днів тому +1

    I have been able to run the code, there was no bug but VSC said that it couldn't find the launch.json file thing so it didn't run my code either?? Can anybody help me please?

  • @Ghghgh-tg7ye
    @Ghghgh-tg7ye 4 місяці тому

    Thanks it has worked.

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

    Thanks a lot!

  • @gulamnabikagathala3762
    @gulamnabikagathala3762 8 місяців тому +2

    what about java and c++ both it is giving errer it is compiler with json the c file

  • @crusatyr1452
    @crusatyr1452 26 днів тому +1

    6:05
    After clicking on the first one, I get an error reading:
    The preLauchTask 'C/C++: gcc.exe build active file' terminated with exit code -1.
    [] Remember my choice in user settings Debug Anyway Show Errors Abort

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

    how do i use the g++ command and ./a.out command? i used to be able to but i had to reinstall everything on my PC after a wipe and i can't figure it out

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

    My MSYS console did not allow copy paste with ctrl+v. Try middle mouse button or right click the command window, go to options/mouse and check which button is used for copy pasting.

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

    When i went to run the code you wrote in the video i didnt get the hello world message and instead i had a visual studio error that said "Unable to start debugging. Unexpected GDB output from command "-environment-cd" " and the 2 options i had was Open 'launch.json' (it literally did nothing by clicking on it) and the second one was ofc the cancel button... What should i do????? HELP

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

    Thanks a lot brother it worked

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

    It worked sir
    Thank you

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

    Thank You ❤️

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

    You are a lifesaver!!

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

    thanks it acutally works

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

    Its helpful thank you

  • @hajperito7470
    @hajperito7470 3 місяці тому +2

    I have a problem with launch.jackson please help

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

    Thank You 🔥

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

    Thank You!!!!

  • @YTSniperJaguar
    @YTSniperJaguar 18 днів тому

    Ive been trying to get my compiler to work for days i reset started fresh still same problem i dont get it stressful

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

    this video makes ME STRESSED!

  • @hashiramuhape2046
    @hashiramuhape2046 11 днів тому

    Hey guys please I'm having issues with downloading the msys2 on my pc
    Any time i click the download link it tells me the page can't be reached

  • @shrav.10
    @shrav.10 5 місяців тому

    Great vid !

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

    Much appreciated.

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

    I need help, after the installation of MSYS2 when I run it, mine got # sign not $.
    It can't even copy n paste the step 4 pls help

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

    THANK YOU