On This Page
This document provides instructions for setting up a programming environment for use in CS-11. The environment is called Cygwin and is installed using babun (pronounced like "Baboon"). Babun includes not only Cygwin but other addons like an easier-to-use installer and package manager, both of which make installation easier. For a two minute video overview see: Introduction to the Babun Project.
If you are looking for instructions on setting up g++ for Mac OS X, see: How to Install g++ on the Mac
- Go to the site http://babun.github.io.
- Click the Download now button and save the zip file to a easily acessed place like the Desktop or Downloads folder.
- Unzip (Extract All) the downloaded zip file.
For instructions on how to unzip files for Windows see: Zip and unzip files.
- Install by double-clicking
install.bat (Windows Batch File) inside the unzipped
- After the terminal window appears, type the following commands and press the Enter key after each command:
pact install gcc-g++
pact install astyle
- To verify that your installation was successful, type
g++ in the terminal window and press the Enter key. The message "no input files" will appear if you were successful.
If you were not successful then try the following steps in order:
- Restart Babun and again verify by repeating step 6.
- Reinstall Babun again starting with step 4.
- Reinstall Babun again starting with step 3.
- Uninstall Babun by double-clicking the
uninstall.bat from the installation folder and then install Babun again starting with step 1.
Installation folder usually:
If not there, open the Babun window and execute:
- Email the instructor with a description of the problem including any error messages or a screenshot.
- Bring your computer to the instructor, a classmate, or a tutor for hands-on help.
- As a final step, set windows to show filename extensions. In addition, you may remove the downloaded zip file and unzipped folder from you computer.
Compiling and Running Programs
In this section we look at how to compile and run C++ programs using your Cygwin installation.
- Copy the following program into a text editor like TextPad, Notepad or Notepad++.
using namespace std;
cout << "Hello, World!\n";
} // end of main function
Note that MS Word, or any other word-processing program, is NOT a good choice for a text editor. You can make them work but they are too cumbersome and error prone for working with source code.
- Save the above program file in your Cygwin home directory using the file name:
The Cygwin home directory for Babun is
C:\Users\username\.babun\cygwin\home\username where username is the login name for your computer. Make certain that you save the program with the correct file extension of
cpp. Windows will automatically add the wrong file extension, unless your text editor is showing the Save as type: "All files (*.*)" in the box under the file name.
- Start Babun by double-clicking the babun icon on the Desktop or selecting
babun.bat from the Start menu.
- In the command window, use the
ls (el-es, not one-es) command to list all your files. You should see
hello.cpp in the terminal window like the following.
If you do not see the file listed, then you did not save the file in the same folder that Cygwin is viewing. Try again to save the file in the correct folder.
- Compile the hello.cpp program by typing the following command at the command prompt and then pressing the Enter key:
g++ -Wall -Wextra -Wpedantic -o hello hello.cpp
After running the command, you should see a window like the following:
Verify the file compiled by typing
ls (el-es, not one-es) and make sure you can see the
- To run the program type the following and press the Enter key:
After running the command, you should see the terminal display, "Hello, World!", like the following:
In Case of Trouble
- If you try to compile and see a message like, "fatal error: stddef.h: No such file or directory", then update g++ with the following command:
pact update gcc-core gcc-g++
After the update, verify you can compile and run.
Last Updated: September 05 2018 @17:01:58