Setting up a Simple MinGW Evironment on Vista

January 18th, 2008

I am currently taking a course in C programming. This is virtually free credit for me since I’ve been programming in C++ for many years, through which I’ve become familiar with C. The course includes three lectures held by Dr Jonas Skeppstedt who wrote the second validated C99 compiler.

This course includes four assignments and naturally these were meant to be done on a Unix system with GCC. However, as the counterproductive Linux-hater which I am I decided to do it in Windows Vista with MinGW. Here is my step-by-step guide to compiling crap in C99 with MinGW on Vista:

  1. Install MinGW. Does this seem easy? It is! Just download the “Automated Installer” from Sourceforge.net and run it.
  2. Create your working directory anywhere you want and make a .bat file with these lines:
    @ECHO OFF
    SET MINGWROOT=C:\MinGW
    SET MINGWBIN=%MINGWROOT%\bin
    SET MINGWINC=%MINGWROOT%\include
    SET MINGWLIB=%MINGWROOT%\lib
    SET MINGWGCC=%MINGWROOT%\libexec\gcc\mingw32\3.4.5
    SET MINGWWBI=%MINGWROOT%\mingw32\bin
    SET MINGWWSC=%MINGWROOT%\mingw32\bin\ldscripts
    SET MINGWPATH=%MINGWBIN%;%MINGWINC%;%MINGWLIB%;%MINGWGCC%;%MINGWWBI%;%MINGWWSC%
    
    SET PATH=%MINGWPATH%;%PATH%
    
    cmd

    This saves you the trouble of having to edit Vistas Environment Variables, which is not a good idea anyway since (1) you dont need to and (2) if you are unlucky you can get conflicts with Cygwin or other programs

  3. Start up your batch file and do something like
    gcc -std=c99 test.c -o test

The C:/Mingw directory above is of course replaced with your MinGW installation directory.

  1. giry Says:

    On xp the bat its the same ?
    thx

  2. Jean-Pierre Says:

    Hi,

    Thanks it works perfectly for me :-)

    Jean-Pierre

Leave a Reply