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 😄!
I've been looking for a video like this. I always struggle to compile but now, it's not a problem. Thank you!
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.
brother, my compiler is still not working properly could you please help me
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!
The only tutorial that actually worked for me! Thank you!!
The other ones 😞. They are really useless
@@thabomaleke874 Yea
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.
same here! all possibilities ! really well explained, well done man!!!
incredibly greatful for such a nice simple put tutorial!!! Very straight to the point! love it, thanks a ton:D
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.
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 :)
my problem right here, life saver
ive been trying to fix this problem all day when all i had to do was restart my computer, thank you
your a life saver, its 5:35am and im so tired of trying to get this thing to work
You actually only need to close all VSCode windows so that the Path changes take effect.
Is there an error like this
The preLaunchTask 'C/C++:gcc.exe build active file' terminated with exit code -1 ?
Thanks very much. You really helped me a lot.
Very simple and straight-to-the-point video.
Thanks a lot once again.😊
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.
Which step are you failing at?
@@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
@@KennyYipCoding same, when i run there's no "C/C++ :g++.exe build and debug active file"
@@KennyYipCoding yeah me too i try that for three times
@@farisraid7588 Try restarting vs studio
This is so well-made, thank you!!
Subscribed, keep up the good work
Thank you very much for uploading this to the point tutorial! I could get cpp running in one go :)
I watched so many tutorials but this one worked thanks 😊😊
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.
helpful and to-the-point thanks for this!
the best video i have ever watched . you explained this in detail and clearly thank you.
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.
After 3 attempts, it worked out. Thanks for sharing
Thankyou so much !! you've made it easier for me.
I done installation within few minutes.I've been looking for a video like this.thanks a lot!!
I think you are a teacher. Life made easy. Thanks.
Fantastic tutorial, was searching through a few videos to get started on c++ and this one was the best
Perfectly running after your tutorial thanks.
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!
Thank you my friend, helped alot. All the best! 🙏
Thanks! This was very helpful for me.
You saved me after 4 hrs of trying to run my code and facing problems thanks 😂
Worked in my case finally I am using vs code thankyou bro.
Thank you so much! Very Helpful!
It worked for me. Thanks :)
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.
it still doesn't work
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
Instead of pasting it on path of user variable, paste it on path of system variable
thank you it worked after doing as u said@@vinamrajeet
THIS WORKED TYSM
thanks men i really appreciate u giving such a detailed explanation video
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
Thanks man! Great video!
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 .🥰🥰🥰💗💗💗
such a great and helpful video ! Thank you very much :)
Thank you so much! You saved my life 😁
Thank you for your work
Very well explained. Thank you for this wonderful video :)
Thnaks a lot Buddy that was a 10/10 helped me 1000%
Thx u Kenny! All Done!
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?
You are such a goat for this thank you 🙏
It really worked for me.
Thanks 🙏 i have gone through many tutorials but this one only this worked❤
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)"
same bro
Appreciate the help.
THANK YOU, it finnaly works.
Thank for this helpful video❤
Great and quick tutorial!
Your tutorial is great, it realy helped me. 😀
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."
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
thank you so much... very clear tutorial..
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?
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?
The only tutorial that has actually worked! Thank you so much
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?
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. 🔥
The best so far...ty
thank you very much , I have subscribed to your channel
Thank you so much man
is that any way to hide that long blue colored line before the actual output?
i surfed many videos and finally found this
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?
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
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
@@sofiaholguinjimenez5657 thanks bud this worked for me too, though the first time i ran it my antivirus detected it as a trojan lol.
Thank you very much, good luck.
Thank you so much it works for me
Life saver man
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 ?)
thank you! Do you have a tutorial to be able to compile C++20.? your instructions are easy to follow, ty! appreciate your videos!
thanks it was really helpful
Easy and simple. New sub
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?
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
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
In final step,Instead of c/c++ g++ debug, i have c/c++ gcc . I dont know how to change ??
Thank you so mcuh!
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?
Thanks it has worked.
Thanks a lot!
what about java and c++ both it is giving errer it is compiler with json the c file
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
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
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.
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
Thanks a lot brother it worked
It worked sir
Thank you
Thank You ❤️
You are a lifesaver!!
thanks it acutally works
Its helpful thank you
I have a problem with launch.jackson please help
Thank You 🔥
Thank You!!!!
Ive been trying to get my compiler to work for days i reset started fresh still same problem i dont get it stressful
this video makes ME STRESSED!
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
Great vid !
Much appreciated.
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
THANK YOU