How to Fix Error: GCC/G++ No Such File Or Directory

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys in this video I'm going to show you how you can solve a problem which appears while compiling your C or C plus plus programs which says no such file or directory so let's say I want to uh compile this main dot CPP file so I have created this main dot CPP file on my computer and I have written this program now I want to run this program so I will write this G plus plus command and then hyphen o and give the name of my output file for example main dot exe file and then I need to give the name of my CPP file but for some reason I just missed the name of my C plus file and I give the wrong extension for example instead of CPP file I just write main dot C right and when I press enter it says no such file or directory this problem occurs when you don't provide a correct file name while you compile your C or C plus plus program so you need to make sure that you are in the correct directory in which you want to run your C plus plus program right so my my C plus plus program is in my c apps directory so I am in the correct folder but I have provided the wrong file name right also let us say my extension is CPP right which is the extension of this file dot cpb but the file name I provide here is wrong so I can just say main dot CPP this is also going to show me this kind of error or if I have some space in the name of the file it's going to show me the same error right so to solve this error you need to go to the folder where you want to run your C plus plus or C file as in my case I am in my c apps folder and there is this main.cpp file but from this command line how you can make sure on your Windows operating system that what are the files available in the current directory you can give this command d i r command so just write dir and then press enter and once you write dir it's going to show you all the files which are present in your folder so the file name is main dot CPP file right right now I am opening my Powershell same you can do on the normal command prompt or The Terminal right so I can just right click here where my main dot CPP file or main.c file or whatever your COC program file name is just go to the directory right click there and then click on show more options if you don't see these options and then click on open in terminal and then just write dir to know the file content and you can see the file contents are main.cpp so the file name is main.cpb so if you are not sure just give the d i r command and you will see the file name there then you can simply write G plus plus and then hyphen o the name of your exe file which will be the output file which you will run after compiling your C plus plus program and then the name of your file which is main dot CPP right if you open the Powershell and you can just write main here and then press the Tab Key the Powershell also is going to auto complete your file name so if you have doubt just write first few letter of your file and then press Tab Key on your keyboard on your Windows operating system and the Powershell is going to auto complete your command right press enter and once you press enter it's going to create this main.exe file for you right so let me do it in my visual studio code editor also and let me remove this uh exe file let me move it to recycle bin and then I give the command G plus plus hypheno main.exe now I give the right name here which is main.cpp and then press enter and you can see it creates this main.exe file I can run this main.exe file by just writing main dot e x e and then press tab here okay when you press tab on Powershell it's going to add dot backslash automatically for you this is how you run your exe file on Powershell if you run command prompt so from here on Visual Studio code I can even open command prompt and on command prompt you can just give the name of your exe file directly and then press enter and you can run your program or you can open CMD here and then go to your folder and from there also you can run your file in a similar way so this is how you can solve this problem on your Windows operating system I hope you've enjoyed this video and I will see you in the next video
Info
Channel: ProgrammingKnowledge
Views: 46,617
Rating: undefined out of 5
Keywords: no such file or directory gcc vscode, gcc error: no such file or directory, make g++ no such file or directory ubuntu, gcc no such file or directory but file exists, c no such file or directory but file exists, no such file or directory c++ visual studio code, make: g++: no such file or directory, no such file or directory in vs code
Id: pcaByFmyP-s
Channel Id: undefined
Length: 6min 35sec (395 seconds)
Published: Tue Apr 11 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.