Docsity

Installing Cygwin -Beginning C Programming for Engineers - Notes | CSCI 1190, Lab Reports of Computer Science

Toggle sidebar
bg1
CSCI 1190 (Sections 1, 3, & 5)
Instructor: Minoo Aminian
Fall 2008
The purpose of this handout is for you to learn how to create, compile, and run a C program. We
run our programs in Unix. In Windows, you can provide Unix-like environment by installing a
package called Cygwin. I will go over Cygwin installation briefly. If Cygwin is already installed
on your computer you can skip the following section and start the exercise.
Installing Cygwin
1. Start by going to the http://www.cygwin.com and click on “Install Cygwin now” button
to the top right corner. Download the setup file to a folder that you can find it.
2. Double click on setup.exe; click next and select “Install from Internet”; click next again.
3. The panel “Select Root Install Directory” should show up with the default directory as
“C:/Cygwin”, click next.
4. You can continue by clicking next for the next two panels: “Select Local Package
Directory” and “Select your Internet Connection” set to their default values.
5. Then you should see “Select Download Site” window. You can choose a site, any sites
and then click next again.
6. Now you will see “Select Packages” window. In this window there is a column to the left
labeled category, underneath you can find the word “Devel”, click on that. It should
expand to a list of packages.
7. Scroll down to find a package named “gcc-g++”. Click on the word “skip” on the same
row to select it.
8. If you want to install xemacs, click on the category “Editors”. Then find the the package
xemacs and select it.
9. Click next and wait for the download to complete.
10. Finalize the installation by clicking “Finish” in the last pop-up window.
pf2

Partial preview of the text

Download Installing Cygwin -Beginning C Programming for Engineers - Notes | CSCI 1190 and more Lab Reports Computer Science in PDF only on Docsity!

CSCI 1190 (Sections 1, 3, & 5)

Instructor: Minoo Aminian

Fall 2008

The purpose of this handout is for you to learn how to create, compile, and run a C program. We run our programs in Unix. In Windows, you can provide Unix-like environment by installing a package called Cygwin. I will go over Cygwin installation briefly. If Cygwin is already installed on your computer you can skip the following section and start the exercise.

Installing Cygwin

  1. Start by going to the http://www.cygwin.com and click on “Install Cygwin now” button to the top right corner. Download the setup file to a folder that you can find it.
  2. Double click on setup.exe; click next and select “Install from Internet”; click next again.
  3. The panel “Select Root Install Directory” should show up with the default directory as “C:/Cygwin”, click next.
  4. You can continue by clicking next for the next two panels: “Select Local Package Directory” and “Select your Internet Connection” set to their default values.
  5. Then you should see “Select Download Site” window. You can choose a site, any sites and then click next again.
  6. Now you will see “Select Packages” window. In this window there is a column to the left labeled category, underneath you can find the word “Devel”, click on that. It should expand to a list of packages.
  7. Scroll down to find a package named “gcc-g++”. Click on the word “skip” on the same row to select it.
  8. If you want to install xemacs, click on the category “Editors”. Then find the the package xemacs and select it.
  9. Click next and wait for the download to complete.
  10. Finalize the installation by clicking “Finish” in the last pop-up window.

Exercise:

Now let’s try Cygwin by running a sample program.

  1. Double click on Cygwin icon on your computer.
  2. Make a directory(folder) to hold you’re your lab exercises as follows: mkdir CS119 0
  3. Open that folder/directory by typing: cd CS119 0
  4. Suppose you write a program called first.c. To type/edit your program you can open an editor of your choice (e.g. notepad or xemacs) by typing: xemacs first.c
  5. Type in your program: /* First Program in C / #include <stdio.h> / function main begins program execution / int main() { printf( “Welcome to C!\n”); return 0; / indicates that program ended successfully / } / end function main */ Save your program after you are finished typing and editing.
  6. At the Cygwin prompt, to compile the program type: gcc - ansi – pedantic – Wall – o first first.c
  7. If there is no syntax error, run the program by typing: ./first