Cygwin and G++

For Cygwin/X:
Go to http://xfree.cygwin.com/
click on the Install Cygwin/X now hyperlink
download the install file
open it and follow the onscreen instructions


Windows XP/2000/NT install guide:
_________________________________________________________

So you want to code in C++ using your home computer? There are two things that you will need--an environment to code in and something to compile your code. Since we will be graded based on how the g++ compiler compiles our code, this is going to be the compiler we want to install!

Installing the g++ compiler:
The easiest way to install the g++ compiler is by allowing a program to do it for us! The program “Cygwin” is by far the easiest way to install the C++ compiler.

Cygwin is a Linux-like environment for Windows. It consists of two parts:
* A DLL (cygwin1.dll) which acts as a Linux API emulation layer providing substantial Linux API functionality.
* A collection of tools which provide Linux look and feel.

The g++ compiler is one of the tools included in that second part. We start the process by downloading and installing Cygwin from the developer’s website:
http://www.cygwin.com/
Near the middle of the page, you’ll see the download link.

You can either run the exe directly, or save it to your system. When the exe is launched, you will have to go through a bunch of prompts. You’re going to hit ‘next’ six times (stick with the default options), which will bring you to the “select packages” screen.

Find “Devel” and click on the little cyclic arrows next to it until it reads ‘Install’ off to the right. You are now going to scroll down the list and do the same thing for “Net”. This tells the Cygwin installer to install both the Devel and the Net tools.

Hit next and give it plenty of time to install. (Wait for “Installation Complete”.)

Now that the Cygwin tools are installed, we have only 1 more step before the g++ compiler is ready to be used. You have to tell your computer the location of the compiler. To do this, go to Start --> Settings --> Control Panel. Switch to ‘classic mode’ (selectable on the left side) if you are currently in ‘category view’. Click on System (you can also access this by right clicking on ‘My Computer’ and going to ‘Properties’). You now need to go to the Advanced tab and then click on Environmental Variables. Look for Path under the “System Variables”.

Click Edit and add the “c:\cygwin\bin” directory to the end of the path, using a semicolon to separate the new entry, like this:
other stuff;c:\cygwin\bin

Hit OK and we are done! g++ should be ready for use! To test that it is indeed working, open your CMD window (Start --> Run --> CMD (enter)). Now in the cmd window, type:
“g++ --version”
Then hit enter. The version information should be displayed. Congrats! You’re good to go!

 

What Next?:
_________________________________________________________

You are ready to start coding. You can code in any plain text editor, or take advantage of several available environments. Eclipse has a plug-in as explained in class. Adobe’s GoLive will do the job. Even notepad will work. I’ve also heard good things about a program called emacs. Check it out. Once your code is written and saved locally (as a .cpp file), you can compile it.

In the cmd window (which was used earlier to check your g++ version), you have to navigate through the directories of your computer to the folder in which you saved your code. Inside this cmd window (which now acts more like a linux command window due to our installations), familiar commands such as “ls” (list the files/folders in the current directory) and ‘cd” (change directory) work. Say for example you saved Code.cpp in:
C:\we\love\Adrienne\CSE250
You can type, “cd c:\we\love\Adrienne\CSE250” and hit enter. Now if you type “ls” and hit enter, you should see your file, “Code.cpp”.

To compile this code, type in:
“g++ filename”
Followed up by the enter key.

[or in our case]
“g++ Code.cpp”

If your code is functional, nothing will happen (at least not visually). If your code had any errors or warnings, they will all pop up in your CMD window to laugh at you.

Assuming your code worked, you should now have the code’s default output in your directory. Type “ls” and you should now see “a.exe” in your current directory. Simply run this to view your results! [Run it by typing in “.\a.exe” and hitting enter].

CONGRATS!

Note that you can also pass in parameters when you compile your code to change the output filename. To do this, type “g++ filename –o DesiredOutputName”. There are numerous other parameters that may be helpful if you spend some time to look them up.

ALSO NOTE: You will be graded based on how the Timblerlake/Nickleback servers compile your code! It is therefore important to make sure your code compiles correctly on those servers! Discrepancies can occur due to the compiler version or even due to the difference in computers! One thing that may be worth doing is checking your version of the g++ compiler (using the “g++ --version” command in the command window) against the CSE server’s version. (Cygwin allows for different versions of g++ to be installed if you browse through the “Devel” options during install).
You can do the set up from on campus and off campus