Microcontroller Embedded C Programming Lecture 8| Installing compiler (GCC) for host (WINDOWS)

 

Installing compiler (GCC) for host (WINDOWS)

 

 

 

How to install gcc in windows?

First, download the MinGW 64-bit or 32-bit version. So, type MinGW 64 bit in Google and go to this link mingw-w64.org .

Figure 1. mingw 64 bit official link
Figure 1. mingw 64 bit official link

 

  1. First, go to downloads.
  2. And Click on MinGW-w64 builds option. 
  3. Click on Mingw-builds, installation:sourceforge. So, click over this. 
  4. And wait for some time, and you must download the Mingw-w64-install.exe file. These steps are shown in Figure 2.
Figure 2. Downloading the MinGW 64-bit version
Figure 2. Downloading the MinGW 64-bit version

 

And also, you must install MSYS. For that, go for this option Installation: GitHub. So, click over this link, and it takes you to msys2.org. 

Figure 3. MSYS2
Figure 3. MSYS2

 

Figure 4. MSYS2 Installation
Figure 4. MSYS2 Installation

 

And here, you can see  Download the installer, as shown in Figure 4. Click over that option. 

 

Let’s install the MinGW toolchain—double-click over that application. (shown in Figure 5)

Figure 5. MinGw toolchain
Figure 5. MinGw toolchain

 

Now click Next.

Figure 6.Welcome page of MinGW-W64
Figure 6.Welcome page of MinGW-W64

 

Here, if you are installing a 32-bit version, you select i686, or if your machine is the 64-bit version, then you can go for x86_64. So, it’s better to install the 64-bit version. So these options please don’t change (Figure 7). And now, let’s click Next.

Figure 7. Mingw settings
Figure 7. Mingw settings

 

The MinGw application will be installed here, as shown in Figure 8. Please note this path because we will be referring to this path later. Now click Next.  

Figure 8. Installation folder
Figure 8. Installation folder

 

It will take some time to install all the files. Now let’s click Next to continue the installation.

Figure 9. Installation Files
Figure 9. Installation Files

 

Now the installation is over. Click Finish.

Figure 10. Installation Completed
Figure 10. Installation Completed

 

And we have also downloaded the MSYS2 installer. We have to install this. So, double click over that, and click Next, as shown in Figure 11. 

Figure 11. MSYS2 64 bit setup
Figure 11. MSYS2 64 bit setup

 

You select the installation folder and click Next.

Figure 12. Installation Folder
Figure 12. Installation Folder

 

Click Next, and you must complete this installation.

Figure 13. MSYS installation
Figure 13. MSYS installation

 

Now the installation is completed. You need not run this, so uncheck this Run MSYS2 64bit now option. Then, click on Finish.

how to install GCC in Windows
Figure 14. Complete the installation

 

After the installation, we have to verify by running some MinGW and MSYS commands.

For that, open the command prompt. And  type’ gcc.’ You can see that it says ‘gcc’ is not recognized as an internal or external command. And you also type ‘rm’ here, it says the remove command is not recognized. 

Actually, we have already installed the MinGW toolchain and the MSYS toolchain. Still these commands are not recognized. So, to get rid of this problem, we have to do path setting.  

how to install GCC in Windows
Figure 15. Command Prompt

 

For that, Go to Properties and select Advanced system settings. Here, open Environment variables. (see Figure 16)

how to install GCC in Windows
Figure 16. Advanced system setting

 

Here you have to modify some user variables. We have to edit this user variable, that is, path. Select the path option and click on Edit.

how to install GCC in Windows
Figure 17. Path setting

 

And select New to add a new path. 

The first path is the path where the MinGW tools are present, and another is where the MSYS files are present.

how to install GCC in Windows
Figure 18. Edit environment Variable

 

How do you get that path?

Go to the Installation folder of MinGW. So, that is actually under C → program files → mingw-w64 → open that. Go under x84_64-8.1.0-posix-seh-rt_v6-rev0 → mingw64 → open the bin, and there are some tools. And select the path and copy it, as shown in Figure 19.

how to install GCC in Windows
Figure 19. MinGW path

 

And you paste that path into the environment variable, shown in Figure 18.

 

For the MSYS2 path, go to the C directory – msys64 – go under usr – bin and copy the path and come over to the environment variables to paste that path.

how to install GCC in Windows
Figure 20. MSYS path

 

You have added the MinGW and MSYS path and then click OK, OK, OK.

 

Now reopen the command prompt and Type ‘gcc.’ It should be recognized. And the remove command also should be recognized, as you can see in Figure 21. 

how to install GCC in Windows
Figure 21. Command prompt

 

These two commands we use to compile and clean the project. That’s a procedure to install a GNU tool for windows. 

In the following article, I will cover for Linux and Mac.

 

FastBit Embedded Brain Academy Courses

Click here: https://fastbitlab.com/course1

 

FastBitLab

The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries.