Using C++ under Unix

If you want to work from home, it might be easiest to use C++ on the College of Engineering Unix cluster (wolf, dingo, ...). Here are very concise instructions.

Create a Separate Directory

The first thing you will probably want to do is make a separate directory to hold the C++ files of your program. Do this using the command
      mkdir assign1
or any other name you may want to give to the directory instead of assign1.

Each time you want to work on your assignment, you will have to enter this directory with the command

      cd assign1
(To get back after you are done with your work, just enter
      cd
by itself.)

Create C++ Files

When you are in the directory you can create a new C++ file, say program1.cpp, by, for example,
      pico program1.cpp

Instead you might want to download C++ files in the directory from the course Web page using Netscape, say. That is usually done by clicking the left mouse button on the file you want to download and selecting the "Save As.." option. Do not forget to select your assign1 directory while doing this, or the files will go to the wrong place.

You might also want to transfer in C++ files from the P.C.s using FTP. To transfer a file, say func2.cpp from a P.C. to Unix while sitting at the P.C., use WS-ftp. Open ftp.eng.famu.fsu.edu, a Unix system, using your Unix username and password. Then select ASCII as transfer mode, click on the file to transfer and then click the arrow between the windows. The file will be transferred.

Back on the Unix machines, you can use pico to change your C++ files as needed.

Create the Executable File

To compile the files program1.cpp and func2.cpp together and create an executable called runprogram1, you would enter
      c++ -o runprogram1 program1.cpp func2.cpp
You would then enter
      runprogram1
to execute it. If the program comes with a makefile, instead just enter
      make
Use
      ls
to figure out the name of the executable that has been created by make, or have a look at the makefile using either pico or more makefile.

Mailing Your Program to the Instructor

The simplest way to mail the program1.cpp file to the instructor is
      mail dommelen < program1.cpp
but better is to include a subject:
      mailx -s "Here is my project 1!" dommelen < program1.cpp
Note the x at the end of mailx.

To make sure you are mailing the right thing, you may first want to look at the file using

      more program1.cpp
If you cannot read it this way, the instructor won't be able to read it either.

Caution

Safety First

Under Unix, it is very easy to do major damage by deleting the wrong files. (Deleting files is done with the rm, remove, command in Unix). If you want to have some protection agains this, edit your startup file as follows:
      cd            # to make sure you are in the right place
      pico .cshrc   # to edit the startup file
(the comments starting with sharps are not needed) then add the following lines at or near the end of this file:
     set noclobber              # avoid clobbering files

     alias rm 'rm -i'           # safe remove
     alias del 'rm -i'          # can use the DOS command del instead of rm

     alias cp 'cp -i'		# safe copy
     alias copy 'cp -i'		# can use the DOS command copy instead of cp

     alias mv 'mv -i'		# safe move
     alias move 'mv -i'		# can use the DOS command move instead of mv
     alias ren 'mv -i'		# can use the DOS command ren instead of mv

     alias dir 'ls -lF | more'  # can use the DOS command dir instead of ls

Exit pico and make the changes effective immediately using

     source .cshrc
You only need to do all this once.
Return to the class web page.
Return to my home page.
Comments: dommelen@eng.famu.fsu.edu