Well.. since we are talking about Arch Linux.... the current version of vscode in Arch Linux seems to use a different marktplace where the microsoft c/c++ extension isnt available in ... so you will need to manually download the vsix file and install 'manually' the extension... for those who may need it...
thank You so much! i started using garuda linux since i find that my games run better on arch than debian and i want to still be able to do some programming but i swear, trying to find help for C++ support in vscode for arch is a pain in the butt. if i get it working then you will be my favorite person of the week lol
wow, I searched everywhere for an answer for why I was getting a JSON error when trying to compile and run a C file in visual studio code... this video was so informative. I wish I found this hours ago.
Thank you so much. I couldn't get a C++ file to compile. I read the documentation for VS Code, and it talked about the tasks.json and the launch.json, but it gave such vague guidance. My frustration was going through the roof. All the other UA-cam videos were not helpful as well. Your walk-through tutorial was SO HELPFUL is getting VS Code to finally work with C++.
@@porcohuetropadocafe20k15 E aí mano, só vi hj a sua mensagem, eu já programo no linux, Ubuntu, eu precisei baixar o visual Studio Code e tbm um negócio pelo terminal, q eu não me lembro o nome
Not sure why I was having a 'could not find/launch' error, which then the VScode told me to launch the json file, but somehow I deleted all the .vscode files, uninstalled all extensions and followed your tutorial from the beginning and it worked. Thank you.
Just a quick observation. If you want to compile and debug C++ files, in the "tasks.json" file, in line 7, the command should be "/usr/bin/g++" instead of "/usr/bin/gcc".
Thank you for a nice presentation, I want to add that sometimes you need to install GDB as it is not installed to default location on Linux, /usr/bin/gdb
Thank you that was very helpful. One thing i found out though, the memory part of vscode is not implemented in debugger. I use that to see how variables are stored ie structs, arrays etc, very helpful for understand how information is stored. So I continue to use code-blocks so that I can look at memory contents.
I use VSCode for C on Linux but I use vscode-clangd. Which is just a language server no debug or compile. I created a simple C program to execute the first line of the current file after the last // // LIVE // sudo gcc -Wall -s -o /usr/local/bin/notify notify.c notification.c $(pkg-config --cflags --libs libnotify) // TEST // gcc -Wall -o notify notify.c notification.c $(pkg-config --cflags --libs libnotify) && ./notify I have a single global task setup in VSCode mapped to F10 that passes the full path of the current file. Works on any type of file and is available in every VSCode workspace without any setting up task.json and launch.json. So much easier and quicker for small projects.
Really nice solution! It's always a hassle to set up all both tasks.json and launch.json every time I create a small project. I use the same environment for all the videos so I don't have to deal with that. Another solution would be to make a softlink to an external .vscode folder.
Great video, but seems like a pain to do that for each workspace. I think I may just use the editor, and use a makefile for build and gdb for debugging. Thanks for sharing!
You are a Holy Man! I just have a question, I am using the opencv4 library and every time I need to compile my code I have to put " g++ -o main main.cpp `pkg-config opencv4 --cflags --libs` " in the terminal. How should I configure the .json file to obtain the same result by pressing F5 into VSCode? Is the thing that you did with "example" working also when you #include other local files? like an inherited class and so on
Yes, I think in this case you should use make or cmake to compile your program. And it's basically the same as in the video except you change the commands to cmake. Just make sure you are compiling with the debug flag enabled, otherwise you can't debug your code
Thanks for this good video, do you have information about import c++ eclipse project to visual studio code? C++ has two types of compilation one for release and one for debug?
Thank you for a great video. Everything works as shown. I would like to use the commands cin and cout available in "iostream". How do I add a setup, so it can find the include files with writing "" for every include file I would like to use?
very helpful but i have a problem the #include i marked as red theres an error on building: /home/{name}/Desktop/C++/main.cpp:1:10: fatal error: studio.h: No such file or directory 1 | #include
Thank you so so much. Launch works using F5 however, I wonder why I get an error if I launch from the top-right play button (Run C/C++ File or Debug C/C++ FIle)? An error pops up indicating the file does not exist. Thank you :)
/usr/bin/gcc : The term '/usr/bin/gcc' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
I used to run the program through the editor but for some reason is not working. I can manually compile it but I am trying to go back to how it was. Do you have any idea why I can not compile it through the editor? All the setting you had provided is the same on my end. I do not know what to do.
Thank you for the video! It really helps! My only problem is that when I press F5 to complie my main.c code, I get a "MIDebuggerPath" error. How do you fix this?
Either missing gdb or the miDebuggerPath is pointing to the wrong executable. Run the command "whereis gdb" and paste that there. Here is some more info stackoverflow.com/questions/56344186/unable-to-start-debugging-the-value-of-midebuggerpath-is-invalid
There are videos for linked lists and arrays and a lot more. I put them in playlists although not all of the videos are in a particular order (the linked list playlist is tho!): ua-cam.com/channels/6qj_bPq6tQ6hLwOBpBQ42Q.htmlplaylists
Hi, I have a question. I want to create a game with OpenGl and I need to install some external libraries. However I have no idea how to tell VSCode where they are located. For example I get this error: "GLFW/glfw3.h: No such file or directory". How can I link my libraries to my project? I have them saved in a lib folder - lib/GLFW/inlcude
There is the c_cpp_properties.json file in which you can add additional include folders. Add that folder there. That'd be the first step. Then, in the gcc command, make sure you have -lglew (or whatever library you need to link to when compiling)
Hi, is it important for the type to be "shell" instead of "cppbuild" (because when I click the same thing you did, my type is cppbuild instead of shell, and my "cwd" are {fileDirname} instead of ${workspaceFolder} ) I tried both but got "Cannot build and debug because the active file is not a C or C++ source file." instead :( what should I do? thank you :)
I'm assuming the cppbuild type is used by the C/C++ extension. Make sure the tasks.json has the same contents as here: code-vault.net/lesson/4wy66ezt7u:1610303902122
Hi, I have a problem while debugging, a message come out saying "Terminal will be reused by tasks" I can´t see the program printing the "Hello World" running the program steps by steps. I am running on Raspberry Pi 4
You can check what these all mean: code.visualstudio.com/docs/editor/variables-reference Usually you want to use workspaces where possible, so I think you can simply change from fileDirname to workspaceFolder and you'll be fine
I found that on Arch-based systems, the equivalent to getting build-essential is:
sudo pacman -Sy base-devel
Thank you so much
Well.. since we are talking about Arch Linux.... the current version of vscode in Arch Linux seems to use a different marktplace where the microsoft c/c++ extension isnt available in ... so you will need to manually download the vsix file and install 'manually' the extension... for those who may need it...
@@Gunnl Thank you!
I've used "sudo pacman -S gdb". i dont know the difference :/
thank You so much! i started using garuda linux since i find that my games run better on arch than debian and i want to still be able to do some programming but i swear, trying to find help for C++ support in vscode for arch is a pain in the butt. if i get it working then you will be my favorite person of the week lol
this tutorial is just perfect! helped me not only to setup, but to really understand what's happening. thank you for that.
wow, I searched everywhere for an answer for why I was getting a JSON error when trying to compile and run a C file in visual studio code... this video was so informative. I wish I found this hours ago.
Don't stop making videos. Your explanation to every step is really good. Thank You.
Thank you so much. I couldn't get a C++ file to compile. I read the documentation for VS Code, and it talked about the tasks.json and the launch.json, but it gave such vague guidance. My frustration was going through the roof. All the other UA-cam videos were not helpful as well. Your walk-through tutorial was SO HELPFUL is getting VS Code to finally work with C++.
Man I really don't know why this video hasn't blown in millions of example like literally. It really helped me set up my vs code. Thanks man!
you saved my life learning c, started yesterday and didn`t understand how to set this up on linux, you are a lifesaver
I'm a brazilian programming student, I'm larning C in my university ,and you help me very much with this video, thanks for share this knowledge
Cara, pode me ajudar? É somente baixar o vs code e a extensão? Quero migrar para o linux, somente necessito saber disto
@@porcohuetropadocafe20k15 E aí mano, só vi hj a sua mensagem, eu já programo no linux, Ubuntu, eu precisei baixar o visual Studio Code e tbm um negócio pelo terminal, q eu não me lembro o nome
@@porcohuetropadocafe20k15 Mas eu acho q se vc baixar só as extensões dá tudo certo
Eu fiquei uns 2 dias só tentando, foram tantas coisas q eu nem sei oq fiz pra dar certo
Em geral a única coisa q muda do linux pro windows é um negócio q tem q baixar, não usei pra praticamente nada oq o cara mostrou no vídeo aí
grateful for finding this channel, keep up the good work , you are making my uni life easier.
Not sure why I was having a 'could not find/launch' error, which then the VScode told me to launch the json file, but somehow I deleted all the .vscode files, uninstalled all extensions and followed your tutorial from the beginning and it worked. Thank you.
the effort and enthusiasm he puts in the guide is contagious
your a god! first video that got me working c working on VS code!!
Actually I was frustrated for a whole day, but this tutorial saved me from having hard time! Thanks a lot! 🕊️
Brilliant presentation! Particularly helpful on the subtle changes to tasks.json and launch.json!!
Respect.....now I know that I am not the only one that creates a development folder with all my projects in there 👍
It helps me lot, I tried to configure task & debugger for ubuntu. Finally It helps me lot. Thank you so much.
Thank you so much! this really helped me setup my gcc in Manjaro!
finally a good tutorial man the way u explain is awesome love ur vids man.
Thanks, that was very useful and helped me to do the initial configuration regarding these 2 files (tasks.json and launch.json). 🙂
Thank very much for the donation!
Mulțumesc pentru explicație! Sunteți tari!
setting up vs code never been so easy thanks to you
Just a quick observation. If you want to compile and debug C++ files, in the "tasks.json" file, in line 7, the command should be "/usr/bin/g++" instead of "/usr/bin/gcc".
Thank you. I waste some time to discover that!
so if I'm building both C and C++ code I need to keep constantly changing this?
Yuu saved my life dude
You are amazing bro. You solved a week-long-of-trying problem. Thank you so so so much. :)
#include has to be added in example.c . thanks a lot for clear explanation.
Thank you so much ,it worked perfectly well on my kubuntu 20.04 LTS.
Thank you so much this worked on my VSS on Ubuntu 22.04 !
This tutorial is amazing, you convinced me doing this configuration instead of using code runner !
This rescues my leetcode competition. Hats off
Thank you for a nice presentation, I want to add that sometimes you need to install GDB as it is not installed to default location on Linux, /usr/bin/gdb
u really covered all of my doubts in this one video.......thank u so much.........appriciated
in germany we call people like you "Ehrenmann".
just the video I needed at this point of time thanks a lot!!
You are the best teacher ever! Big thanks
Absolutely briliant!
You always do everything right, thank you!
Allah senden razı olsun arkadaşım. Çok işime yaradı.
Thank you man.
Thank you that was very helpful. One thing i found out though, the memory part of vscode is not implemented in debugger. I use that to see how variables are stored ie structs, arrays etc, very helpful for understand how information is stored. So I continue to use code-blocks so that I can look at memory contents.
That's what I'm looking for...thanks man! It helps a lot.
amazing, this is the best tutorial out there by far
Very good tutorial. It was way easier than setting this up on windows.
Thanks a lot, this video was extremely accurate and
you saved so many of my hours.
Thank you for this tutorial! Extremely helpful and well explained!
It Was Awesome , extremely informative and easy to understand , thank you
Thanks a lot. It worked for me!
I am using msvc compiler with vs code. It was very hectic using msvc compiler for the first time. 🙂
nice small tutorial, perfect to build my helloworld.
I use VSCode for C on Linux but I use vscode-clangd. Which is just a language server no debug or compile.
I created a simple C program to execute the first line of the current file after the last //
// LIVE // sudo gcc -Wall -s -o /usr/local/bin/notify notify.c notification.c $(pkg-config --cflags --libs libnotify)
// TEST // gcc -Wall -o notify notify.c notification.c $(pkg-config --cflags --libs libnotify) && ./notify
I have a single global task setup in VSCode mapped to F10 that passes the full path of the current file. Works on any type of file and is available in every VSCode workspace without any setting up task.json and launch.json.
So much easier and quicker for small projects.
Really nice solution! It's always a hassle to set up all both tasks.json and launch.json every time I create a small project. I use the same environment for all the videos so I don't have to deal with that. Another solution would be to make a softlink to an external .vscode folder.
Bro are you on social site
Which social site?
exactly what i needed
Thank you so much for this tutorial!
Awesome video 👍
dude saved my day
Great video, but seems like a pain to do that for each workspace. I think I may just use the editor, and use a makefile for build and gdb for debugging. Thanks for sharing!
To be honest, it never was a pain to do that. I always just copy the files from the .vscode folder to the new workspace and that's it
Exceptionally! Thanks a lot!
Thank you !!!! very good content!!!
THAT'S SO PERFECT!
Damn im really glad i found this video Really helpful!!
NICE VID MAN, THANKS
Thanks you helped me alot ❤
Thank you VERY MUCH 🙏 it helped. At last I got perfect channel 😀
Excellent!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Thank you very much, you explain very well
thank you my brother
You are a Holy Man! I just have a question, I am using the opencv4 library and every time I need to compile my code I have to put " g++ -o main main.cpp `pkg-config opencv4 --cflags --libs` " in the terminal.
How should I configure the .json file to obtain the same result by pressing F5 into VSCode? Is the thing that you did with "example" working also when you #include other local files? like an inherited class and so on
Yes, I think in this case you should use make or cmake to compile your program. And it's basically the same as in the video except you change the commands to cmake. Just make sure you are compiling with the debug flag enabled, otherwise you can't debug your code
Thanks for this good video, do you have information about import c++ eclipse project to visual studio code? C++ has two types of compilation one for release and one for debug?
I haven't used Eclipse. I assume you could just copy most of the source code and compile everything yourself like I showed in the video
thank you so much! This helps a lot
Thank you for a great video. Everything works as shown. I would like to use the commands cin and cout available in "iostream". How do I add a setup, so it can find the include files with writing "" for every include file I would like to use?
iostream is part of the C++ standard library. You need to use g++ instead of gcc and cpp files instead of c files.
Another great video
Thank you very much! I can finally write programs)
Really nice video!
Very usefull video !
very helpful but i have a problem
the #include i marked as red theres an error on building:
/home/{name}/Desktop/C++/main.cpp:1:10: fatal error: studio.h: No such file or directory
1 | #include
nevermind
Super useful. thanks
Thank you so much sir
great, thanks
Thank you !
Thank you so so much. Launch works using F5 however, I wonder why I get an error if I launch from the top-right play button (Run C/C++ File or Debug C/C++ FIle)? An error pops up indicating the file does not exist. Thank you :)
Hmm... Make sure you select from the dropdown the correct lauch.json task. You might have it set to something else
perfect!
Very helpful!!!!!
idk how to say this .... but i love u
this is nice really nice
Could you explain how to use make file with vscode?
I'll look into it
/usr/bin/gcc : The term '/usr/bin/gcc' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Make sure you are on Linux. Seems like you are trying to execute gcc on Windows
I used to run the program through the editor but for some reason is not working. I can manually compile it but I am trying to go back to how it was. Do you have any idea why I can not compile it through the editor? All the setting you had provided is the same on my end. I do not know what to do.
Does it give you an error? Or a warning?
thank you so much
Muito bom, parabéns pelo vídeo!!!!!
Thank you for the video! It really helps!
My only problem is that when I press F5 to complie my main.c code, I get a "MIDebuggerPath" error. How do you fix this?
Either missing gdb or the miDebuggerPath is pointing to the wrong executable. Run the command "whereis gdb" and paste that there. Here is some more info stackoverflow.com/questions/56344186/unable-to-start-debugging-the-value-of-midebuggerpath-is-invalid
@@CodeVault Thank you very much! 😀
I'm still facing issues in making programs in like arrays,linked list etc. Can you make a seperate video for all that?
There are videos for linked lists and arrays and a lot more. I put them in playlists although not all of the videos are in a particular order (the linked list playlist is tho!): ua-cam.com/channels/6qj_bPq6tQ6hLwOBpBQ42Q.htmlplaylists
@@CodeVault Thanks! Waiting for your upcoming videos
toma tu like buen hombre
Hi, I have a question. I want to create a game with OpenGl and I need to install some external libraries. However I have no idea how to tell VSCode where they are located. For example I get this error: "GLFW/glfw3.h: No such file or directory". How can I link my libraries to my project? I have them saved in a lib folder - lib/GLFW/inlcude
There is the c_cpp_properties.json file in which you can add additional include folders. Add that folder there. That'd be the first step. Then, in the gcc command, make sure you have -lglew (or whatever library you need to link to when compiling)
Do you have a tutorial on how to install 3rd party libraries for this setup?
No. But I will look into it in the future
How do I directly open output in my Linux terminal by just click as you open in your videos?
I'm not sure I understand the question. You mean with CTRL + ` by opening the integrated terminal?
Great, but could you explain how to setup c in linux but for pico/stdlib.h, because i am getting error with that library and i dont know why.
Hmm, I'm not familiar with that. What error are you getting?
i have an error Could not load source './libio/iofread.c': 'SourceRequest' not supported..
Hmm, seems like an issue with one of the extensions. Look here for a solution: github.com/microsoft/vscode-cpptools/issues/3831
I get an error when doing the example.c part. I was wondering if I could contact you to get help with this personally?
You can ask here, I try to reply to all the comments
Hi, is it important for the type to be "shell" instead of "cppbuild" (because when I click the same thing you did, my type is cppbuild instead of shell, and my "cwd" are {fileDirname} instead of ${workspaceFolder} )
I tried both but got "Cannot build and debug because the active file is not a C or C++ source file." instead :( what should I do? thank you :)
I'm assuming the cppbuild type is used by the C/C++ extension. Make sure the tasks.json has the same contents as here: code-vault.net/lesson/4wy66ezt7u:1610303902122
Hi,
I have a problem while debugging, a message come out saying "Terminal will be reused by tasks"
I can´t see the program printing the "Hello World" running the program steps by steps.
I am running on Raspberry Pi 4
Hmm, make sure the program compiled without errors. Also check for extra terminals opened on vscode
Best
Thank you, Does it support user input to?
Yea
@@CodeVault I have a problem, the other c file I try to compile still don't follow the settings. How to solve this?
What settings do you mean?
@@CodeVault nevermind bro I solved it. Thank you very great tutorial. Please make more content like this
thanks
In task.json i have "cwd": "${fileDirname}" but yours says "${workspacefolder} can you tell please explain why and how i can change that ?
You can check what these all mean: code.visualstudio.com/docs/editor/variables-reference
Usually you want to use workspaces where possible, so I think you can simply change from fileDirname to workspaceFolder and you'll be fine