Categoría
📚
AprendizajeTranscripción
00:00Hey guys, in this video, I'm going to show you how you can download and install and set up MinGW on your Windows operating system.
00:07Now, first of all, what is MinGW?
00:09So, MinGW is an open source development environment for creating native Windows applications.
00:15It also provides the compiler for compiling the programming languages such as C and C++.
00:23So, let's see how we can install MinGW on our Windows operating system.
00:28So, for that, first of all, open your favorite browser and search for MinGW and you will see the top link here, which will be from sourceforge.net.
00:40Just click on this link, which is in the top results.
00:45I'm going to put this link in the description of this video also so that you can directly reach to this link.
00:51Now, if you see, it has around 3.5 million downloads this week.
00:59So, we are also going to download this file.
01:02So, I'm going to click on this download button, which is going to redirect me to the page where it's going to start the download of this file.
01:12So, you can see this MinGW get setup.exe has been downloaded.
01:17So, once this file is downloaded, just click on this file and then I'm going to minimize the browser.
01:25So, this is the MinGW installation manager setup tool.
01:29So, in here, you just need to click on the install button and then you can verify where MinGW will be installed in your folder system on your Windows operating system.
01:41This is the location.
01:42So, the default location is C colon MinGW.
01:46If you want to change the location, you can click on the change button and change the directory in which you want to install MinGW.
01:53Now, you also have user interface options here.
01:57So, I'm going to leave everything as default and then click on continue, which is going to start the download of all the files which are related to MinGW.
02:09So, here, you just need to wait for a few seconds until those files are downloaded.
02:16And once that process is finished, you will see that this continue button will be active, right?
02:23So, just click on this continue button now and you will see this kind of installation manager for your MinGW.
02:33And then you will see this kind of window.
02:35So, here, you have the basic setup and you will also see all the packages.
02:40So, for now, I want to install MinGW for the compilation process of my C and C++ programs.
02:49So, I'm going to go with the basic setup here and then I'm going to select all these options from here.
02:55So, just right click on these options or click on these options and then click on mark for installation.
03:03Do the same for all the options which are given here.
03:08So, just give mark for installation, mark for installation, mark for installation for all these options here, right?
03:16So, once you have checked all these options, we are going to click on installation and then click on apply changes and then click on apply here, which is going to connect to internet and download all these packages.
03:30So, just wait for a few seconds until those packages are downloaded.
03:35So, after some time, you will see this message which says all changes were applied successfully.
03:41So, we can close this window.
03:43So, I'm going to close this window.
03:44And once you close this window, you will see that all the check boxes are now green and checked.
03:52So, all of these packages are installed successfully.
03:57So, once all of these packages are installed successfully, let me minimize this window here.
04:02And then I'm going to go to my folder explorer.
04:05And then let me go to my C folder here.
04:09You will see there will be a directory called mingw in your C folder.
04:14And when you go inside this C folder, you will see all the files which are related to your mingw compiler.
04:24So, once that's done, we can close this window here.
04:28And now let's verify if everything is working perfectly with mingw or not.
04:34So, first of all, let's go to the location where mingw is installed.
04:38So, I'm going to just open my file explorer and then go to my C directory.
04:42And here you can see we have installed mingw in our C directory.
04:46So, this directory will be available.
04:47So, go inside this and you will see all the files and folders which are related to mingw.
04:53Now, the main folder here is the bin folder where all the binary files related to your compilers are available.
05:02So, the GCC will be used for compiling your C programs and G++ will be used for compiling your C++ programs.
05:10Now, in the next step, we are going to set the environment variable for this directory so that we can use this command from our command prompt.
05:20So, this path is C colon backslash mingw backslash bin.
05:24Right.
05:25So, you need to copy the bin path of mingw.
05:29So, just copy this path and then minimize this window and here search for environment variable.
05:36Okay.
05:37So, just search for environment variable.
05:40And when you type few letters of environment, which says edit the system environment variable, click on this option and it's going to open this kind of window.
05:49So, here click on environment variables and then under system variables, click on path and then click on OK.
05:57And then you need to add this path which we have copied for the mingw in this list.
06:05So, just go at the very bottom and then double click here and then paste the path and then press enter which will add this path for the bin directory of mingw in your environment variables.
06:20Click on OK.
06:21Once again, click on OK.
06:22And then once again, click on OK.
06:24Once that's done, we can verify the G++ and GCC version by opening the command prompt.
06:30So, just type CMD in the search box and then open command prompt and here type GCC space hyphen hyphen version and then press enter and it's going to show you the version of GCC which is 6.3.0.
06:47And then similarly, we can type G++ space hyphen hyphen version and then press enter and it's going to show us the G++ version.
06:56Now, we can also compile our C and C++ programs using this G++ and GCC commands, right?
07:08So, for that, what I'm going to do is I'm going to just go to any folder of my choice.
07:15So, let me go to my documents folder and then in the test folder, I'm going to create a C file and the C++ file and compile it using those two commands.
07:26Now, you can use IDEs or editors like Visual Studio Code or any other IDE of your choice to compile your C or C++ code on your Windows operating system.
07:40But for now, I want to show you very basics how you can compile your C++ or C programs using the command line.
07:49So, I'm not going to use those fancy tools.
07:52So, to create a C file, right click here and then click on show more options and here click on new and then you can create a text document here.
08:04So, click on text document and then give any name to your file.
08:10I'm going to name it as hello.
08:12You will also see the extension .txt.
08:14So, I'm going to change this extension to .c which will create a C file and then it says if you want to change the file extension, the file might become unusable.
08:24That's okay for us and you can see the C file is created, right?
08:30So, right click on this hello.c file and then click on open with and we are going to open it with the default editor which comes with your Windows operating system which is Notepad.
08:43You can also open it with your Visual Studio Code but for now, I just want to show you the very basics, right?
08:50So, I'm not using any fancy tools here, right?
08:54Here, I'm going to open the C file and here I'm going to just paste a very simple hello world C program.
09:01You can find it anywhere on internet.
09:03So, I'm not going to show you how to write that program.
09:07Once you have the program, just save this file and then just close this window here and I'm going to open the command prompt so just search for cmd and then open the command prompt and here I'm going to copy this path and then I'm going to cd into this part so I'm going to just write cd and then paste this path which I have copied and then press enter and now I'm in that directory, right?
09:32In order to compile this hello.c file which is available inside your test folder, let me give this dir folder and you can see hello.c file is available.
09:46To compile this just write gcc space hyphen o and your binary name, I'm going to name my binary as hello and then your c file name which is hello.c in my case and then press enter.
10:02It's going to compile your code and then it's going to create this binary on hello.c file.
10:09Let me do this side by side so you can see this in action, right?
10:14Let me delete this .exe file and give the same command again and once I give the same command, you will see this exe file is generated, right?
10:24That means we have successfully compiled our code and to run our code just write dot forward slash and the name of your exe file which is hello.exe.
10:37You can also just write hello.exe here and then press enter and it's going to print the hello world output here.
10:50So this is the output of our c program, right?
10:54Similarly, you can create a c++ file.
10:59To create a c++ file, right click here and then click on show more option and then click on new.
11:05Once again, similar option, text document and in this case, I'm going to name my file as test.cpp.
11:12So cpp is the extension for the c++ file and then click on yes here and once again open this file with the notepad and then paste the c++ code.
11:24And once you pasted the c++ code, save the file and then to compile this file which is test.cpp.
11:33I'm going to just write g++ because it's a c++ program, right?
11:38Space hyphen o.
11:39Hyphen o is the option for generating your binary file.
11:44So giving your binary file name.
11:46In this case, I'm going to give my exe file name as test.
11:50Whatever file name you will give here, it will provide the same exe file name, right?
11:56So in this case, I'm going to create the test.exe file and then my test.cpp file name is test.cpp.
12:07Give this command, press enter and it's going to create the test.exe which is the compilation output of our c++ file.
12:16So now I'm going to just write test.exe and then press enter and it's going to print hello world once again,
12:23which is the output of our c++ program.
12:26So this is how you can install mingw and use the g++ and gcc command to compile your c and c++ code.
12:36I hope you've enjoyed this video and I will see you in the next video.