Programming assigments and programming environments¶
Note on environment details
Please note that all the details in this document is for the official course environment (linux-desktop.tuni.fi). We can not test the system in all the different environments, so some details might be different on your own computer.
General info¶
The programming project will be done in 2 stages: PRG1 and PRG2. The student repo contains corresponding project skeletons in dirs prg1 and prg2. The student must implement the expected functionality.
Passing PRG1 is compulsory for completing the course. PRG2 is optional, but failing to reach the minimum requirements will have considerable effect on student’s course grade. More details on grading and minimum requirements are shown in the front page.
The amount of work required to complete the project will vary from student to student. However, completing the project will require a significant amount of time. If you start the project a week before the deadline, you will almost certainly encounter problems. Begin planning and coding well in advance of the deadline.
When a deadline is specified, the student must submit their work by 23:59 on that date. (If you wait until 23:55 to start submitting your code and report, expect delays due to peak traffic.)
Programming environment¶
The programming environment is the same used in course COMP.CS.110 Programming2, i.e. C++, User Interface with Qt (which is provided by the course) and version control with Git.
Using your own machine¶
Since the programming assignment involves testing the performance of you code, perhaps the easiest way to do the assignment is to use your own machine and install QtCreator development environment and gcc compiler on that machine. That way other people’s programs don’t interfere with your work and performance tests. You can download Qt development environment for free from https://www.qt.io/download (choose ”Downloads for open source users / Go open source” and in the lower half of next page the button: ”Download the Qt Online Installer”).
- Note 1: The Qt Download needs you to create a Qt user account. You can use your universitu email for this.
- Note 2: Even if you develop your assignment on your own machine, it is recommended to check that the program compiles in linux-desktop, since automatic graders use linux.
- Note 3: If you already have an older version of QtCreator+Gcc installed on your machine, make sure it is new enough to support C++17. It’s advisable to upgrade your installation (to Qt 6.X.X) .
If you have problems, there are general instructions on the Programming 2 course pages.
The following configurations have been made sure to work (if you install the latest Qt 6, that should also work fine):¶
- Windows 11 Qt 6.6.0 and it is important to have MinGW version 11 (that means not 8.something but 11.something), select between 32-bit and 64-bit according to your system, usually 64-bit is the one you want
- Mac OS with ARM-processor: Qt 6.6.0 (of course you need to install XCode or XCode command line tools before this)
- Linux (more specifically Pop!_OS 22.04 LTS with Linux kernel 6): Qt 6.6.0
Remote desktop (virtual machine) for programming¶
If you wish, you can also use remote desktop to virtual machine
linux-desktop.tuni.fi
as your programming environment.
The virtual machine has Git, QtCreator and other editors, Gcc etc. for
programming.
Instructions on how to
connect to the remote desktop
can be found in Intra, and QtCreator instructions
on Programming 2 course documentation pages.
The final programming assigments should work in the remote desktop environment, as that is where assistants will evaluate your work. You can do the actual programming in any environment and any tools you wish, as long as the final assignment works on the remote desktop.
NOTE! When using the remote desktop, put your code into some folder under your ”normal” Linux home directory (/home/yourid/…), NOT under the shared Windows network folder (/intra/home/yourid)! The shared network folders do not work properly under Linux, and for example running your compiled program may be impossible there.
Compiling, testing, and submitting programming assignments¶
Compiling¶
Since the assignment has been written in C++, it must be compiled first, of course. Everyone can do this how they wish, for example:
- Use QtCreator, and compile, run, and debug your program there, with graphical user interface
- Use the Gcc compiler with command line terminal (or some other compiler), in which case the result will be a text-only version of the program (e.g., ”g++ -pedantic -Wall -std=c++17 mainprogram.cc mainwindow.cc rect.cc datastructures.cc -o prg1”).
Testing¶
Your programming assignment has to work correctly with the public test data, but remember also to do your own tests and play with the user interface, because the public test cannot test everything that affects the grading of your work!
For test runs the program must be run in the directory/folder that
contains the project file. If you use QtCreator, you must first
configure the running directory for the project. In QtCreator, click on
the left panel Projects, and then ”Run” (in the Project view there’s a
selection Build / Run under heading Desktop). Now you should see section
Run, under which there is Working directory. Change that to the
directory where the project file is.
(new QtCreator
and old QtCreator
).
If you want to run the program using the command line terminal, go to the directory where project file is (command cd), and then run the program from the directory where it has been compiled/written to, i.e. ”./prg1” (in case of the compile command above). When using command terminal you can also give the executable a test file to run as a command line parameter (in which case the program terminates after reading and executing the test file): ”./prg1 example-in.txt”.
NOTE! The main program prints out to cerr ”Program ended normally” as the last thing if the program completes normally. If the printout doesn’t happen, it means that the program has crashed!
Debugging the use of STL¶
Iterator invalidation, over indexing and errors in using STL algorithms are common and cause often errors that are difficult to find. Fortunately gcc allows compiling the program in ”debug STL” mode, which adds additional checks for many STL-related errors (but not all). If those checks fail, the program is terminated with an error message.
In order to start using debug STL, the compiler just needs appropriate parameters, and the program has to be recompiled. To make this easier in QtCreator, the .pro-file of the programming assignments contain line ”#QMAKE_CXXFLAGS += -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC”, which has originally been commented out. Debug STL is enabled by removing the comment character from the beginning of the line and recompiling the whole program (choose ”Rebuild All” from Build menu). (If you are using gcc without QtCreator, you can just add the ”-D…” parameters to the compiler command, i.e. ”g++ -D…”.)
Please notice that additional checks take time, so the performance of the program is slower when debug STL is enabled, often even asymptotically slower! So make sure you disable debug STL again before running performance tests (re-comment the line and rebuild)!