Learning Linux In Windows - MinGW and MSYS

code ලියන හැටි ඉගෙන ගන්න මෙහාට එන්න.

Moderator: Mr.Angel

Learning Linux In Windows - MinGW and MSYS

Postby Dirae » Sun Sep 22, 2013 6:46 pm


This tutorial will enable you to understand the basic Linux shell get familiar with it while using Windows. We will also be installing a development environment to understand and use major Linux software development tools.

The software that we will be installing are:

1. MinGW (Minimalist GNU for Windows) - MinGW provides an environment for open source development tools, such as GNU Compiler Collection (GCC) and other libraries to be used under Windows. This can be expanded to contain many different compilers such as ADA, Fortran etc to be used for development.

2. MSYS (Minimal SYStem) - MSYS provides a Bourne shell which can be used as a command line interpreter (CLI). This contains many of the native Linux command utilities fully integrated with Windows command utilities and hence can be used as an alternative for Windows CLI (CMD - Command Prompt).

This process will work for both 32 bit AND 64 bit PCs.

Requirements and Process

1. A 32 bit OR 64 bit PC wth a Windows new installation (XP/Windows 7/Windows 8) (Windows Vista is untested)

2. An active Internet connection throughout the installation process.

2. Download MinGW installer.

3. Download MSYS ZIP file.

4. Run the MinGW installer. Use default location "C:\MinGW"

5. After installation, MInGW Installation manager will open. Under "Basic Setup", select "mingw32-base'. Right-click and select "mark for installation". Sect any other compilers that you need, like GNU C++. DO NOT SELECT "msys-base". We will be installing this separately.

6. Select "Installation -> Apply Changes" and wait until necessary files are downloaded and installed. Exit afterwards.

7. Unzip the contents of MSYS-20111123.zip to "C:\MSYS".

8. Go to "System Properties -> Advanced -> Environment Variables" (or "System Information -> Advanced System Settings -> Environment Variables")

9. Locate "Path" under "System Variables" and click "Edit". Under "Variable Value" add the following entries to THE END OF THE VARIABLE FOLLOWED BY A SEMI-COLON (";") FROM THE LAST ENTRY.


My "Path" look like this afterwards:
C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;c:\Program Files (x86)\Intel\iCLS Client\;c:\Program Files\Intel\iCLS Client\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Hewlett-Packard\HP ProtectTools Security Manager\Bin\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Calibre2\;C:\GTK\bin;C:\MinGW\bin;C:\MSYS\bin

10. Go to "C:\MSYS" and execute "msys.bat". Enter the following command:

When requested press "y" for MinGW installation and for the location type EXACTLY "C:/MinGW" (without quotes).

Now you are ready to perform simple Linux commands in the shell and do development.

A Simple Program

Enter the following code in a text file and SAVE as "prg.c" in "C:\MYSY\home".
Code: Select all

#include <stdio.h>

int main(){

   int x=3,b,f=0;

   while (x<=3){
      b = x;
      while (b>0){
         printf (" ");
      b = 7-x*2;
      while (b > 0){
         printf ("*");
      printf ("\n");
      if (f==0){
         if (x==0)
   return 0;

Now run "msys.bat" and type:
cd ..
gcc -o prg prg.c

You will see a diamond shape in the console.

You should probably get hold of a good book on Linux or PM me for recommendations and/or free ebooks. Hope you will make the transition to Linux soon! Your questions, suggestions are feedback are extremely welcome. For further information, contact me on Facebook. මෙම අඩවියේ ලියාපදිංචි වූ භාවිතාකරුවෙක් මෙම ලිපිය සිංහල භාෂාවට පරිවර්තනය කර නැවත මෙහි පළ කරන්නේ නම් ස්තුතිවන්ත වෙමි.
  • 0

"A beautiful thing is never perfect."
Off Topic
Participate in Einstein@Home Project to search for weak astrophysical signals from spinning neutron stars (also called pulsars) using data from the LIGO gravitational-wave detectors.

User avatar
Posts: 2
Joined: Thu Sep 19, 2013 6:46 pm
Location: Kandy, Sri Lanka
Has thanked: 0 time
Been thanked: 0 time
Reputation: 0

Return to Programming Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest