Friday, December 26, 2008

Cygwin - An Intro

Cygwin is not something new for most of you but this blog post is meant for those students/developers who hate using(or at least installing) Linux/Unix on their system (because they have to partition their hard disk) but they have to install it just because they want to use gcc and g++
Because, I have seen many students in my department and in others too, who try to install Linux on their hard disk and in the process either corrupt it or delete some Windows partition accidently, so I hope this entry could be of some help to them.

Though, you always have the option of using Dev C++ or Visual C++, and Dev C++ also claims to be using gcc/g++. (Don't know abt Visual C++)
However, what do you do if you want to use gcc/g++/gdb/make on command line with some command line options like -o, -c, -I, or -shared. What if you want to create a shared library (or a DLL) using gcc on windows ?
One way out(the only way i know of :p) is to use Cygwin, which is nothing but a Unix-like environment for Windows. There are many packages that you can download & install along with the normal base packages to make it function just like Unix. 

I came across it when I started with JNI (Java Native Interface) (a way for Java code to interact with non-Java code....a topic big enough to span another blog entry :-)....see the tutorial for JNI here)
Because, I needed a GNU C/C++ compiler to register with an IDE (in my case NetBeans), so I downloaded Cygwin as per instructions in the tutorial and installed it, though with some problems. But, it was really good to have unix-like functionality on windows system, to be able to execute unix commands from my command line. Now, I do not need Dev C++ to compile my c/c++ programs on windows.
My advice to all budding programmers/students that they must try Cygwin at least once. Try installing it and even if you fumble, there is a lot to help you...try reading setup over the problem and you will be home surely.
More precise and accurate information about how to download and install Cygwin can be found here. A must try even if you are biased towards Java (like me) :-)