How to Install MINGW for Windows Machines

Go to the MINGW website and you should see this screen:

Scroll down until you see "HOWTO Install the MinGW (GCC) Compiler Suite" over in the left side of the screen:

When you click on the link you should see the window below. Click on the link:

Click on MinGW-5.1.4.exe and follow the usual WINDOWS instructions. At some point you may get a warning about updating. Just click "OK" and keep going. It works fine:

When the installer comes up it looks like this (be sure to install everything in C:\MINGW\ -- it makes life easier):

This is what it looks like as it unpacks all the files:

After you click "Next" you are done. At the Command Line to run a C program from the directory that you are using to store the programs, simply type:

C:\mingw\bin\gcc -Wall hello.c -o hello.exe

the "-Wall" tells the compiler to send all warning messages to the screen, the "hello.c" is the C program (it is posted on the website), and the "-o" tells the linker what to name the executable (*.EXE) file. Note that you hit the Enter key after the command and it creates hello.exe.

When you type
Hello at the command prompt and hit Enter Hello world will appear in the window.

Below is a simple batch file -- gcclapack.cmd -- that you should use to compile and link C programs (note that this assumes that you have installed the latest R, version 2.9.0):
c:/mingw/bin/gcc -I"c:/program files/R/R-2.9.0/include" -L"C:/Program Files/R/R-2.9.0/bin" -Wall %1.c -o %1.exe -lRlapack -lRblas
gcc is the compiler (you can always edit your PATH statement to include c:\mingw\bin), -I"c:/program files/R/R-2.9.0/include tells gcc to look for additional header files in that path. (The C Standard Library is in the path C:\mingw\include\ .) -L"C:/Program Files/R/R-2.9.0/bin" tells gcc to look for DLL's in that directory. In particular, the LAPACK and BLAS dynamic linked libraries (DLLs) are in that path. -Wall tells gcc to show all the warnings to the terminal screen. %1.c -o %1.exe tells gcc to compile the C program named "%1".C, where "%1" is a wildcard (see screen shot below) and name the compiled program "%1".exe. Finally, -lRlapack -lRblas tells gcc to also link (include in the executable) the appropriate subroutines in Rlapack.dll and Rblas.dll (these are in the directory C:/Program Files/R/R-2.9.0/bin).

And this is what you should see when you run OLS.EXE: