Make software builds easier...with MinGW

If you have been working in the world of Linux, you get used to a whole host of command line tools simply being available for use during development. One of these is "make", which enables a programmer to define a "recipe" that describes how their application is to be built from the source code.

Graphical user interface tools, such as Atmel's Atmel Studio or even winIDEA, attempt to make the software developer's life easier by grouping the core elements required to build an application from the source code into various menus and window dialogues. But, as software is upgraded or even made obsolete, the rules to build your project's source code can get lost in "project files" that can only be opened by the original GUI software. 

Note: winIDEA actually uses the human readable XML format for its workspace files, so you should always be able to go back and recover any settings that were saved.

Project Build Options: In Atmel Studio, the build options are spread across a broad array of GUI entries

The nice feature of "make" is that the recipe to build your application is stored in a human readable text file that can be used on any operating operating system you choose. It can even be used to build an application on an embedded system if it is running Linux!

Now make is no wonder tool that magically builds your code into executable files - in fact it can be quite frustrating to write the recipes and get make to work (there is help out there though!) However, once you have mastered the basics, it really becomes a great tool to simply build your code, regardless of on what machine you want to build it on, which compiler (or compilers) you need to support, and regardless of the number of different switch options you need to implement (debug version, release version, ...)

Since winIDEA and its Python scripting support, isystem.connect, currently only run on the Windows operating system (Oct 2016), you are probably stuck with using a Windows machine. This is especially true if you want to implement a Jenkins/Hudson Continuous Integration (CI) server for automated builds and testing. And, if this is the case, you probably don't have the make utility on your machine.

There is, however, a solution. MinGW is a project that has put together a minimalist GNU for Windows, making a whole host of GNU utilities available on the Windows command line. In order to make life a little easier, we have put together some instructions below on how to install the tools and make sure they are available when you need them.

  1. Download the “MinGW” package from the link given here.
  2. Launch the setup application which should be named “mingw-get-setup.exe”.
  3. The application should launch with the splash screen shown below in Figure 1


    Figure 1: Splash screen for MinGW

  4. Click the “Install” button to start the installation process. The next step should look like that is Figure 2. It is recommended to install the package in the default installation directory.
    Click the “Continue” button to start the installation.


    Figure 2: Definition of installation directory

  5. MinGW will now install as shown in Figure 3 below:


    Figure 3: Installation of core MinGW elements

  6. Upon completion (Figure 4), you will be able to choose exactly which elements of MinGW you wish to install. We only need “make” which is part of the “msys-base” package. Select the “msys-base” package as shown in Figure 5:


    Figure 4: MinGW package selection


    Figure 5: Selection of "msys-base" package

  7. From the menu, select Installation -> Apply Changes, as shown in Figure 6.


    Figure 6: Apply changes to install "msys-base", including make

  8. The list of changes will be displayed as shown in Figure 7. Simply click “Apply” start the download and installation of the “msys-base” package.


    Figure 7: List of changes required to install the "msys-base" package

  9. MinGW will now download and install the “msys-base” package, displaying the dialogue windows shown in Figure 8 and Figure 9. Close the window once the installation is complete.


    Figure 8: "msys-base" is downloaded...


    Figure 9: ...and then installed

  10. Once the installation is complete, it is worthwhile checking that the “make” utility is available on your hard drive. As in Figure 10, and if you used the default installation path, you should be able to find “make.exe”

    inC:\MinGW\msys\1.0\bin\


    Figure 10: Location of "make.exe" in installation folder

  11. The final step is to ensure that you can actually call the "make.exe" utility. Open up the command prompt and type "make" followed by Enter. If you receive the output:

    make: *** No targets specified and no makefile found. Stop.

    then the command line environment knows where "make.exe" is installed. Congratulations - you are ready to make!


    Figure 11: Testing 'make' at the command line

  12. If you see the following (Figure 12):

    'make' is not recognized as an internal or external command,
    operable program or batch file.

    then the environment variables for your system need modifying so as that Windows knows where to find make.


    Figure 12: The most typical failure - Windows can't find 'make'

  13. We need to tell Windows the path where 'make' is to be found. Let's start by opening the "System Properties" by typing "control system" followed by Enter at the command line. The following window should open (Figure 13):


    Figure 13: System Properties dialogue

  14. On the left-hand side, click on the text "Advanced system settings" to open the System Properties "Advanced" tab (Figure 14):


    Figure 14: System Properties, "Advanced" tab

  15. Next, click on the button "Environment Variables..." to open the dialogue as shown in Figure 15:


    Figure 15: Environment Variables dialogue window

  16. We will change the "Path" variable for the system, so that all users can make use of the "make" utility. If you prefer, you can just change the "Path" for your user account instead. Simply select the "Path" entry (as in Figure 15 above) and then click the button "Edit...".


    Figure 16: "Edit environment variables" dialogue window

  17. Click the "New" button (see Figure 16) and paste the path to the MinGW msys folder. If you used the default installation setting, the path will be:

    C:\MinGW\msys\1.0\bin\

    Click the "OK" button on all open windows to save the settings and close the dialogue windows.

    Now, close your command line window (in order that the command line can reload the new "Path" setting), restart the command line and type "make" followed by Enter. You should see:



    Figure 17: 'make' now available from the command line

If you managed to make it through all that, you have not only successfully installed the "make" utility, but you will also be able to call it from the command line or from your Jenkins/Hudson environment to build your projects.

We hope that helps you get another tool in place for a successful Continuous Integration (CI) setup - in the mean time, Happy BugHunting!