Step 2: Install a Compiler

Objective: Install MinGW to compile an .c file and then create an .exe executable.

2.1: Install a GCC compiler

We will use MinGW to compile our assembly projects

  1. Find the installer on MinGW’s site or download it from this site directly.

  2. Note the default the installation directory and then press Continue.

    Caution

    • MinGW might not work correctly if you install it in another directory other than the default.

    • So, we recommend using the default installation directory.

    image1

  3. The installer will download and install MinGW.

  4. Verify that the installer downloaded and installed all selected items.

    image2

  5. Select mingw32-base-bin and apply changes.

    • From the menu: Installation Apply Changes

    • The installer might take a while depending on your internet connection.


    image3

    image4

  6. Press the Close button when the packages finish downloading.

    image5

  7. Verify that ming32-base-bin installed.

    image6

  8. You can now close the installer window.

2.2: Set the path to GCC

Windows needs to know where to find gcc.exe, which it will do by setting the path=C:\MinGW\bin;%path%

Tip

  • Set the path to your compiler in the Windows path so that all applications can find it.

  • Otherwise, you have to specify the full path to the compiler.

Verify the programs execute in CMD

Note

This path is set ONLY for this CMD instance. You have to run the command again when you close the CMD window. Or, you can specify the absolute path to the file.

You can add it permanently the System Environment Variables.

  1. Open up Command Prompt (CMD)

  2. Set the temporary path by executing: path=C:\MinGW\bin;%path%

  3. Verify the path set correctly

  4. Type: echo %path% image9

  5. Type: gcc --version Verify that it displays the file version. image10

Errors

If you get a not recognized error, then the path is not set correctly or you installed MinGW in a different directory.

image12

  1. Try executing it using the full path: C:\MinGW\bin\gcc --version

  2. Verify the installation path: dir C:\MinGW\bin

Set path in Windows System (standard user)

  1. Open the Environment Variables for your account

    • In the start menu type: edit environment variables for your account

  2. Select on Path and then click the Edit button.

  3. Add an new path to C:\MinGW\bin

  4. Or, append ;C:\MinGW\bin to the end of another path

Set path in Windows System (with Admin)

  1. Open the Advanced System Properties in Windows. There are several ways:

    1. Copy and paste one of these commands to Windows Explorer or Start Menu

      • Advanced System Settings
        -OR-

      • C:\Windows\System32\SystemPropertiesAdvanced.exe

    2. Navigate from the control panel: Control Panel > System and Security > System

      image21

  2. Click on the Environment Variables button

    image22

  3. Select Path under User variables and then click on the Edit button

    image23

  4. Click on New and then add a variable for the bin folder of GCC: C:\MinGW\bin

    image24

  5. Press OK on all windows

  6. Close and reopen the CMD windows to get a new prompt.

  7. Verify that GCC display the versions correctly before continuing.

    image25