2421 Home
Syllabus
Lectures
Homework
Final Project
Programming
Links

 


Programming Guideline
  

For the source code sharing and grading purposes, we must have a common programming environment. Everyone should have an access to it and the compiler must be the latest ANSI/ISO C++ compliant. The common compiler platform for this course is GNU g++ version 4.8 or later available on csegrid.ucdenver.pvt.  Every CS student should have an account on csegrid.ucdenver.pvt  from the department.

If you prefer to work on your own PC, Clion is a good programming environment. It is free for students, and it supports C++ IDE that provides an integrated development environments including editor, project manger and debugger. You can download it from https://www.jetbrains.com/clion/. If you're not familiar with various programming environement listed below, I would recommend you to use Clion for programming on your home computer.

Belows are other possible platforms:

If you're familiar with Linux, All Linux comes with GNU g++ version 4.8 or later compiler.  It's robust, and free for you to download. In addition, it will be an excellent opportunity for you to learn Unix/g++ environment if you're not familiar with it.  If you want to install Linux/g++ on your home PC, One of the solid distribution is Ubuntu Linux (www.ubuntu.com), and you can download free ISO CD image files and burn your own CDs. It comes with g++, and many other utilities.

If you use a Mac, install the developer tools (gcc and all necessary packages) available in the Mac OS X system disc or from the web site http://developer.apple.com/technologies/tools/ 

If you use Windows platform but want to use a GNU complier, you can download Cygwin from http://www.cygwin.com/ for free. It's basically a GNU compiler ported on Windows. 

Also on a Windows 10 platform, you can use Visual Studios Community at https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx.

You can use all these other compilers in various platforms but then you have to be very careful to check the compatibility. I have a few cases where a code compiled and run fine on one platform and had many problems on others. I can not accept a claim "My code compiles and runs fine on my home computer".

Also, we will be doing a lot with pointer programming so I recommend you to use a good debugger. All programming IDE above comes with some variations of debugger.

If you have to use other programming environment because of your work or home situations, I recommend you to finish working on your platform and test on gcc again. To convert DOS file into Unix file, you can use dos2unix command.

%dos2unix mydosfile.cpp

All homework will be tested and graded with GCC 4.8 or later on csegrid.ucdenver.pvt Linux. If it runs fine on that platform, you'll get full credit.

 

 

How to connect and tranfer files to CSE Server

You can remotely access the CSE Linux server.

If you're accessing csegrid server from outside of the campus, you must be on the University VPN. Here's how to connect to the University VPN.

Basic terminal access
Connect to the load balancer csegrid.ucdenver.pvt via ssh using the client of your choice.  A very simple one is putty available here

If you're using Mac, you can use the built-in mac terminal and connect to the server by "ssh csegrid.ucdenver.pvt" at prompt.

File Transfer between your home computer to csegrid.ucdenver.pvt

You can use a file transfer client such as FileZilla, a free ftp client. Download it and connect to csegrid.ucdenver.pvt. Again, make sure you're on the VPN.

 

Please refer to this tutorial for a detailed instruction with accessing the csegrid.

CSE_Grid_Tutorial

C++Code

Documenting and submitting programs

Every programming assignment should be submitted electronically before the due date and time. We're going to use Canvas file upload system for submission. Click the link at the homework description page.


Each programming assignment should include

  • your source code and Makefile
  • a README file documenting, briefly
    • your name and student ID
    • a brief description of your program (both file organization and high-level description of the program and its main features, see the sample readme file in the sample file 1234HW1.zip)
    • the status of your program (e.g. it works completely, it compiles but doesn't run, it compiles and runs but doesn't work in certain cases, some features are missing etc.)
    • what hardware platform(s) you tested it on.  
    • how to compile the program (e.g. "run 'make my-hw1-solution' using the submitted makefile") and how to run it.
    • Sample Readme file is available here. Refer to it and follow the guidelines.
  • Do not include binary files.
  • Create a directory, put all files in it, and name the directory "xxxxHWn", where xxxx for the last 4 digits of your student ID (SSN), and an n stands for the homework number . For example, if you're submitting homework 1 and your id is 1234, the directory name should be 1234HW1
  • Compress the directory into one file. Use the same name for the compressed file (i.e. 1234HW1.zip). If you don't create a properly named directory and compress files in the current directory, the your files could be mixed up with other students' when I uncompress them. So please do not forget to create a directory and compress the directory.
  • Here's a sample homework submission file 1234HW1.zip

 

How to compress a directory on Unix

 You can use zip command for compressing a directory. For example, if you're about to convert a directory named 1234HW1 into a file 1234hw1.zip, use following function at the prompt:

% zip -r 1234hw1.zip 1234HW1
 

To unzip

%unzip 1234hw1.zip

Here's an alternative using tar and gzip but you may not need this.  You can use tar command on Linux/Unix to make a directory into a file.

%tar -cvf 1234HW1.tar 1234HW1

To compress the file, you can use gzip:

%gzip 1234HW1.tar

Then it will generate a compressed file 1234HW1.tar.gz . If you want to uncompress it  

%gzip -d 1234HW1.tar.gz

or use unzip command.

To untar, you can use

%tar -xvf 1234HW1.tar

 

If you're using Linux with the latest GNU tar (Our lab Linux boxes are equipped with this), tar command has compression option by itself. To tar and compress 1234HW1 directory,

% tar -cvzf 1234HW1.tgz 1234HW1

To untar and uncompress

%tar -xvzf 1234HW1.tgz

 

Make Utility

Make utility allows simple compiling and linking with just one command.  Visit http://www.gnu.org/software/make/ for a short tutorial. 

This is a short youtube tutorial for Makefile.

Here's a sample source code with Makefile for you to use. To compile and link, all you have to do is type "make" at the prompt. Make utility compiles and links only new or updated files. This Makefile defines which files are source code and what file name you want to use for the final executable program.

For example, if you uncompress sample source code with Makefile, on your csegrid.ucdenver.pvt account, you'll see a folder named "1234HW1"

In that folder you'll see several *.cpp files (source code), *.h files makefile, and readme.txt.

At the prompt, type "make" and enter.

Then g++ will compile 3 source code and generate an executable file "matrix".

That's because in the Makefile line 14,

OBJS = main.o matrix.o matrix_functions.o

indicates that main.cpp matrix.cpp matrix_functions.cpp are source files for the project.

 

Also take a look at the Makefile line 16,

TARGET = matrix

this line indicates that the final executable file name would be "matrix".

Remaining part of the sample makefile needs no modification in most cases no matther what c++ source code you're compiling or linking.

For example, following lines in the Makefile are applicable to all *.cc, *.c or *.cpp files so you don't need to change. Note that those indented blanks in front of $(CC) are all ascii tab character, not space character.

$(TARGET): $(OBJS)
       $(CC) -o $@ $(OBJS) $(LIBDIR) $(LIBS)
.cc.o:
       $(CC) -c $(CXXFLAGS) $(INCDIR) $<
.c.o:
       $(CC) -c $(CXXFLAGS) $(INCDIR) $<
.cpp.o:
       $(CC) -c $(CXXFLAGS) $(INCDIR) $<

 

In summary, all you have to do for future programming is to edit two lines from the sample Makefile

OBJS = filename.o .... (source files that ends with .cc or .cpp)
TARGET = binary_filename (executable filename you want to create)

It's also very easy to delete all binary files including *.o, executables, and core dump. All you have to do is type "make clean". It will delete all non-text files. Make sure that you run "make clean" before you compress the folder into *.zip file for submission, so that no binary files are included in the submission.

If you want to use this Makefile for other projects, in most cases, all you have to do is replace the source file name (from matrix.o  to the new file names ) and executable file name (from matrix to the new executable file name).

 You have to provide a Makefile for your homework submission.

Creating Unix Library