by June 7, 2004 0 comments

You can have Windows and Linux in two separate partitions but can’t use both at the same time. If you want to use an application on one of the OSs, you need to boot from that OS. Using both the OSs simultaneously enables a developer to run and test his application much faster. We will explore how to run a Linux application natively on Windows using Cygwin, which does it without having to install Linux. Cygwin provides a standard Unix/Linux development environment and you can also migrate Unix/Linux applications to Windows. To test this, we ran mplayer, which is a Linux-based media player, and the GCC compiler to compile a C program. 

Linux and Windows developers
No need to install Linux

To install Cygwin, download the setup.exe file from By default, setup.exe installs only the base Cygwin distribution. Run the setup.exe file to install the Cygwin environment and GNU packages. Select ‘install from Internet’ as download source. Install Cygwin in c:\cygwin. Select ‘All users’ from ‘Install for’ option and Unix from Default Text File Type. Click on Next and select the directory c:\cygpac for GNU package installation. Select ‘direct connection’ option for connecting to the Internet. Select an HTTP site for installing Cygwin and GNU packages. There, you will get an option for downloading the packages you want to install. You can either select individual packages or install all the packages. We installed all the packages. To install all packages click on the label (default) next to all. Note that the installation of all packages takes time and lots of hard drive space. It’s not recommended if you’re on a slow Internet connection.

Once Cygwin has been installed, you can run it by double clicking the icon it creates on your desktop. In case the icon is not there, go to the Cygwin directory and click on cygwin.bat to start it. Use the following commands to access the Cygwin environment. 

cd /cygdrive /c
cd cygwin

You are now in the cygwin directory.

Now, let’s run a .mpeg file (video) using mplayer. For this download the tar file from while working in Windows. Copy this file in the c:\cygwin directory. Now run the Cygwin environment and untar the tar file using the tar -jxvf command. A folder with the name of the tar file will be created, say mplayer. Under the Cygwin environment, its path will be /cygdrive /c/cygwin/ mplayer. Copy the .mpeg file in this folder. Now you need to configure and compile the mplayer using the following commands. 

./ Configure
Make all

To run the MPEG file (ensure that you are in /cygrive/c/cygwin/mplayer directory), look for a file called mplayer.exe, and run the following command. 

mplayer.exe MPEG file name

You have to replace MPEG file name with the name of the actual file. The resolution of the MPEG file
can be varied by adding the parameters “-x 800 -y 600” to it. 

Now, let’s write a C program and save it as .c file in the cygwin directory. For example, we saved it as check.c. You need to compile this file using GCC complier. Make sure you are in cygwin directory. 

Type the following command to compile and run check.c file.

gcc check..c -o check.exe

You will get the desired output.

Sushil Oswal

No Comments so far

Jump into a conversation

No Comments Yet!

You can be the one to start a conversation.