How to Install MinGW (GCC/G++) Compiler in Windows 11

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 download and install mingw on your windows 11 operating system so min gw provides the tool set to compile your c or c plus plus programs on your windows operating system using gcc or g plus plus so let's see how we can download and install mingw so first of all open your favorite browser and search for bin gw and in the search result you will see some websites so don't click on the first website which you will see here which is from sourceforge you need to open this website which says mingw hyphen w64.org so just click on this link which says mingw hyphen w64.org and once this website opens you will be able to see the overview here and on this website you can click on the downloads link here so here you will be able to see all the download link for bing w for different operating systems so the one we are looking for is the windows version so we are going to click on this link which says mingw w64 builds so just click on this link which is going to open this kind of window again and from here you can download the mingw builds from sourceforge so you need to click on this link now right so sourceforge link was shown directly in the search result but you need to go through this website in order to come to this website and once you are redirected to the sourceforge.net website you will see that min gw 64-bit installer exe file will be downloaded on your windows 11 operating system so once this file is downloaded i'm going to click on this file and then you will see this warning which says do you want to allow this app from unknown publisher to make changes on your device i trust this so i will click on yes here and i'm going to minimize this browser and you can see mingw installer has been started on my windows 11 operating system so on the first window i just need to click on next here which is going to start the installation here you can choose the version for mingw so i'm going to choose the topmost option which is 8.1.0 at the time of making this video you can also choose the architecture i'm going to choose x 8664 and then you can choose the threads so generally for threads i always choose pause 6 but you can also choose win32 also also exception you have two options i will leave it as default and then you have the build revision i will leave it as default also and then click on next and this will be the location where your mingw compiler will be installed so you can see it will be installed in the program files min gw directory will be created and then this folder will be created right so if you don't have the good reason to change this location just leave it as default and also you can leave this checkbox as checked which is going to create a shortcut for your mingw uh compiler tool so i'm going to click on next now which is going to start the download of all the files and packages for your mingw tools so just wait for this process to reach to the 100 mark so now after some time i can see this window it says click next to continue the installation so i'm going to click on the next and now i can see this message it says mingw has been successfully installed and i can click on finish to complete the installation so let me click on the finish button so once i click on the finish button mingw is installed on my windows operating systems so now once mingw is installed first of all we need to know the location where mingw is installed so at the time of installation you might have noted the location so let me show you the default location where mingw will be installed so you need to go inside the c directory and then go inside program files and then you will be able to see this mingw hyphen w 64 bit folder here and then this folder will be there so this is the location where mingw is installed then you need to go inside mingw64 and here under the bin folder you will see all the files which will help you to compile your c or c plus programs okay so go until the bin folder right and you need to copy this path now we need to set the environment variable for mingw so that we can use gcc or g plus plus command on our windows command prompt or powershell or terminal so for that what you need to do you just need to click on search and then search for edit env and it's going to show you this result which says edit environment variables for your account and you can see this window is going to open right now if you can't find this edit environment variable window using the search option then you can always open the control panel and then once control panel opens you need to view by category here and then click on system and security and then once again click on system here which is going to open the settings app and here it's going to show you an about section this link which says advanced system settings so just click on that and then click on environment variables which is also going to open the same window so you can choose any one of the method so once this environment variables window opens select path under system variables and then click on edit and then click on new here okay so it's going to allow you to add a new environment variable and then just copy the path until the bin folder inside your mingw64 bit folder okay so this path is until bin folder okay and once you copied it you can just add this path here inside your environment variable and then just press enter which is going to add your path and then click ok here and then click ok and then once again click on ok and now you can close all the windows here and now we can test our gcc and g plus plus versions and commands right so you can open the command prompt by just pressing cmd and then open the command prompt from the result and once the command prompt is open here you can just write gcc space hyphen hyphen version and then press enter and if you see some result which looks like this that means gcc command is working successfully on your windows 11 operating system similarly you can also check the g plus plus command which is also used to compile your c plus programs so it's also going to show you this kind of result here so once you see this kind of result that means your gcc and g plus plus commands are working so let me show you how you can compile a very simple c program using gcc on your windows operating system using the gcc command so for that you just need to uh go to the location where you want to uh create uh your c file so i'm going to go to this folder which is under my documents and here i'm going to right click here and windows by default is not going to allow you to create c files directly so you need to create a text file first of all and name your file something so in my case hello and you can see the extension here hello dot text right if you don't see dot text extension here you can click on view and then click on show and then click on file name extension so this options should be selected in order to see this dot txt in front of your file once that's done you can just rename your file and then instead of dot txt just give the extension dot c and then press enter and then press yes which is going to create a hello.c file for you once that's done you can just copy the path where your c file is present and then once again open the command prompt and then just write cd and then paste the part which you have copied and then press enter and from here you can compile your c program so first of all you need to write some code inside your c program right so just open this c file with notepad generally we use some sophisticated editors like code blocks or visual studio code or some other ides to write our c or c plus program but let me also show you how you can do it without them so once your hello.c file is opened you just need to uh copy and paste a very simple c program inside it and then save it you can just press ctrl s to save it or just click on save from here and once your c program is saved you can go to the location where your c file is there and then just write gcc and the name of your file in my case my file name is hello.c and then space hyphen o hyphen o is the flag which you use to provide the name of your output binary or executable file so hyphen o and then the name of your executable file so for example i'm going to just say out here okay so this is the c a program i want to compile and once it's compiled successfully the binary will be called out or let me just name it output right so output and then press enter which is going to compile your c program and if it doesn't contain any error then it's going to create this output.exe file right so in order to run this output.exe file you can just write dot forward slash and the name of the file which is output.exe and then press enter which should show you the result but it says dot is not recognized as an internal or external command so this is how you run it in your linux operating systems in order to run your output file in windows you just need to write output.exe and then press enter which is going to just show you the output in my case a sample c program was printed because in my c program i was just printing a sample c program here right if your program contains some error let me remove this semicolon from here for example and then save it and then run the compile command once again which is gcc hello dot c hyphen o output file and now it shows me the error right because if your program contains some error it's going to show the error where this error is coming from so you can see this error is coming from the line number five okay so i can just go to the line number five and then fix the semicolon once again because it says expected semicolon before return right so i can fix it and then save it and then compile the program once again and then i will be able to see the output once again right so i can just write output.exe and it shows me the result once again so this is how you can install and use mingw on your windows 11 operating system i hope you've enjoyed this video and i will see you in the next video
Info
Channel: ProgrammingKnowledge
Views: 116,625
Rating: undefined out of 5
Keywords: MinGW, GCC, G++, Windows 11, Install MinGW, How to Install, How to Install MinGW, Compiler, GNU, Windows, Microsoft, Microsoft Windows, MinGW - Minimalist GNU for Windows download, MinGW C++ Download and Installation Instructions, How to Install the MinGW Tools for C/C++, How to Install MinGW | GCC Toolset for C and C++, Installing MinGW & MSYS on Windows, Installing MinGW
Id: fsmVbLMzBoo
Channel Id: undefined
Length: 12min 49sec (769 seconds)
Published: Tue Nov 30 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.