How to set up C++ in Visual Studio Code
Вставка
- Опубліковано 25 вер 2024
- How to set up C++ with Visual Studio Code (vscode).
Install Visual Studio Code: code.visualstu...
Install minGW (C++ Compiler): code.visualstu...
Steps to setup minGW in windows:
1. Install MSYS2 using the link provided by microsoft github.com/msy...
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 😄!
Thank you so much. I started my first computer science class and was lost in the sauce. I didn’t know anything about what to install and how to install it. That is until I saw this video. Thanks to you I was able to print my first Hello World ! 😊
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!
finally someone who goes over everything, spent two hours trying to figure this out, 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
@@shuaibakhtar5333 Uninstall everything and go through harry's guide
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.
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!!!
The only tutorial that actually worked for me! Thank you!!
The other ones 😞. They are really useless
@@thabomaleke874 Yea
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 ?
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
I love you. I have spend AGES doing this and this finally worked.
BRO, THANK YOU SO MUCH! YOU ARE AWESOME! I was suffering the whole day, and can't understand why VSCode is not working i swear i felt like I'd been all over the internet to find something about my problem BUT you're video help me. Thank you again pal!!!
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
uninstall valorant
@@acombo I never installed it in the first place
for me it wasnt the first one that showed up. make sure you press the one that has g++.exe not gcc.exe. that fixed it for me
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.
I've been looking for a video like this. I always struggle to compile but now, it's not a problem. Thank you!
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. 🔥
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.
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!
Took me the entire day just to set this up because of you, I can now turn to a new page. I THANK YOU, GOOD SIR.
trying since yest but finally able to run my prog with help of the clear instructions you have provided on this video , Thank You !
Thanks very much. You really helped me a lot.
Very simple and straight-to-the-point video.
Thanks a lot once again.😊
Thank you so much! A try a lot of videos and always struggeles in running C and C++ code . Regards👏💯
I done installation within few minutes.I've been looking for a video like this.thanks a lot!!
incredibly greatful for such a nice simple put tutorial!!! Very straight to the point! love it, thanks a ton:D
i have constantly failed in installing c++ in visual studio but today i managed to thanks to your video
I successfully downloaded this after a long time fixing erros, thank you very much for this useful video. If someone strugles with VS, I will highly recommand for them this.
the simpilest and the easiest tutorial of running c++. Thanks alot
You saved me after 4 hrs of trying to run my code and facing problems thanks 😂
love this vid! i tried to code in vscode since 1 month ago but vscode can compile the coede and no it worked! tysm
thank you bro I installed g++ and couldn't know why it wasn't working you're a life saver ❤❤
After 3 attempts, it worked out. Thanks for sharing
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.
EDIT: It might not work instantly, you might as well reboot the system first.
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
Thank you very much for uploading this to the point tutorial! I could get cpp running in one go :)
First it did not work, but I figured out it was just because for some reason the user variable thing didn't happen, so I did it again and it works!! tysm!
omgg tysm!!! such a great and comprehencive guide!
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 .🥰🥰🥰💗💗💗
This is so well-made, thank you!!
Subscribed, keep up the good work
Thank you so much for a easy and clean guidance.👍
the best video i have ever watched . you explained this in detail and clearly thank you.
For some people whom this didnt work for, try this. In your workspace folder, navigate to .vscode, and in there, will be a .json file. In that file, try replacing the gcc.exe to g++.exe in both the lines named label and command. That worked for me.
Thank you for saving me
where do i find this workspace folder?
Best guide that worked for me, thank you
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.
My command prompt is showing that " gcc is not recognized as an internal or external command" ......I cant diagnose the problem...
Straight to the point thanks a ton!
The article helped me put C++ into my VS Code. Thanks!
Worked in my case finally I am using vs code thankyou bro.
THANK YOU , NOW I CAN HELP *_MURIAL_* with by coding the *Computer* !!!
It was really a helpful video. It shows the exact procedure line by line. Thanks a lot.
Cristal clear, outstanding!
Thanks, got it at 2 attempts. I got trolled by my pc at download 7 out ot 58 lol just rerun it and worked and smooth sailing at the end.
Thank you my friend, helped alot. All the best! 🙏
THANK YOU SO MUCH YOU HELPED ME A LOT!
I watched so many tutorials but this one worked thanks 😊😊
Great video for beginners! Thank you so much!
Very well explained. Thank you for this wonderful video :)
thanks men i really appreciate u giving such a detailed explanation video
Thank you a lot. I LOVE YOU!!!!
Thank you so much. I've been wanting to learn c++ for a while now but never got the C++ to run 🙏
I don't understand English very well, but I understand your language better than what is shown in my language. Thank you for your help.
Could you solve this issue? It happened to me as well...
Try selecting g++.exe when running instead of gcc.exe. That worked for 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?
please tell me if you'll find an answer
Same problem for me
thank you bro. this helped me a lot.
Helpfull video thank you
🤗
ohh this actually helpful and first youtube tutorial that i watch and it works😮😮
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
Your tutorial is great, it realy helped me. 😀
How can it be so hard to set up a C++ compiler in 2024 😩
For real, it sucks!
use vs community
Frr 😭😭😭😭
@@mijixiiistupid foid! Keys without the e
thanks so much this was a good clean start
such a great and helpful video ! Thank you very much :)
Thank you very helpful!
I am having a problem at the last step where you are supposed to run the program. It says " Launch: Program (then the location in where the file is supposed to be) does not exist" Is anybody else having the same problem?
@mjmrvll Make sure you are in the same directory with the c++ file. And make sure file path to the c++ file does not include blankspaces or non-english characters. File names especially
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.
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?
this is not working for me!!!My command prompt can not show the output that states versions of GCC, g++ and GDB have installed. can you plz help!!
SO am I🥲
Is there any way to remove the blue underlined part at the terminal? It makes things a lot more annoying. Thank you.
Thank you so much! Very Helpful!
I think you are a teacher. Life made easy. Thanks.
alright folkes , everyhing in this video is awesome, just at the moment of running the code don't just blindly click on the first one, click on the one in which there is g++ and not gcc, took an hour+ of my time, but overall an awesome video. (gcc is for c while g++ is for c++ inputs and outputs)
Thank you lol
I did all the steps shown in the tutorial and when it comes to adding it to my enviroment variable and when you enter in the things into the command prompt it keeps saying "'ggc' is not recognized as an internal or external command,
operable program or batch file." Any clue what to do with this?
4:52 bro i cant click it
Finally an easy tutorial with no bullshit that actually works
Thank you so much! You saved my life 😁
I have a problem which says launch problem does not exist... I did everything the same way you did and there is an error about text.exe. I am not sure what it is exactly, because I am still pretty new to coding.
same, haven't found the solution yet
helpful and to-the-point thanks for this!
THANK YOU, it finnaly works.
This works in August 30, 2024. Thanks
Thnaks a lot Buddy that was a 10/10 helped me 1000%
i mean, it works but for some reason the #include keeps getting an error
@Random_Edits-rx3cb well, i mean it still works, doesnt it?
@@itscloudy9246 I have the same. Were you able to find a solution to the problem?
your a life saver thank you so much :) New sub btw.
for me instead of adding in Path under USER variables, I added it to Path under SYSTEM variables and it worked.
What should I do,if when I try to run code it goes out there " launch: program doesn't exist"
even I faced the same problem.
@@joyeetabose5605 You need to install "code runner" extension
@@joyeetabose5605 Did you fix it?
@@joyeetabose5605what to do now???
It worked, thank you so much!
hey yoo,it says launch: program'c:\user\vichy\test.exe' does not exist d
open 'launch.json'
Did you get it to work?
@@projaguar6417 yeh man
How? im still trying to work it out@@Vishnu-fz5zq
@@Vishnu-fz5zq how, whats the fix?
thank you very much , I have subscribed to your channel
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."
it still says "'gcc, g++ or gdb (i tried them all)' is not recognized as an internal or external command,
operable program or batch file."
why wont this work?
Check if you added the path correctly
Doesnt work for me. Says launch program does not exist
I followed your video and it was perfect, thank you. Would you wind detailing how to undo everything, just in case ?
my issue is the "gcc.exe build active file" active thing. and the code won't run causing to have errors and i don't know why cause when i tested the g--, g++ and gdb(which I was following the video steps) everthing is good, just when the time that i run the sample code. it causes error and any sample code won't run.. need help :(
Same
Same
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?
Why "select language" is not showing on my vs code😮😮. I need help please