go to start Ex W1_HS15
|home |print view |recent changes |changed August 15, 2016 |
exact
|You are 3.95.23.35 <- set your identity!

Sections: Installing Virtual Machine | VMWare (Linux, Windows) | Virtualbox (Linux, Mac, Windows) | Login | Mount HSR-Volumes | Cevelop on Windows | Exercises | Hello World | Hello World with separate Compilation Unit | Hello World Library Project and Unit Test | Hello World Class | Compiler Errors | Common Problems |

This week we are setting up your laptops and you will exercise to use Cevelop and the C++ compiler.

We will be providing some memory sticks within the exercise labs to improve installation speed.

The C++ image consists of:


The following instructions need to be checked...

Installing Virtual Machine ^

First you have to download the virtual appliance from the USB stick...

You can either use VMware or Virtualbox to run the virtual machine. The virtual appliance file was created using Virtualbox.

VMWare (Linux, Windows) ^

Download and install the VMware player:

https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/6_0

Start the VMware player, click "Open a Virtual Machine", select the appliance file "CPlusPlus14_64.ova" and then "Open". Modify the name and storage location of the imported image if required. Take care to not store the imported image on a remote file system. Click "Import", the click on Retry if another modal Dialog appears and then wait... Start the VM. open-vm-tools are installed instead of the native VMWare tools to provide copy/paste possibilities.

Due to the fact that the image was created using Virtualbox, you have to change settings here: "System->Preferences->Startup Applications". Uncheck the entry vboxclient but check VMWare User Agent and click on "Close". You have to log out and log in to reflect the changes.

If you still see the message "VBoxClient: the VirtualBox kernel service is not running", make sure you unchecked vboxclient during the procedure above.

If you are not able to seamlessly change the display size by dragging a corner of the window, select a preferred size manually in "System->Preferences->Displays".

You should be ready now to start with the exercises.

Virtualbox (Linux, Mac, Windows) ^

Download and install Virtualbox:

https://www.virtualbox.org/wiki/Downloads or directly via your package manager.

After installation you need to setup the virtual machine. When you started Virtualbox click the "Import Appliance" button, select the appliance file "CPlusPlus14_64.ova" and click "Next". Verify the appliance settings, especially the last entry where your image files are stored and modify if required. Click "Import".

You should be ready now to start with the exercises.

Login ^

Login to the VM using:

User: hsr

Password: welcome

Mount HSR-Volumes ^

There exists an interactive python script, hsrmount.py, to mount some predefined volumes to /mnt. Open a terminal and execute the following command sudo ./hsrmount.py. The script will ask you for your hsr shortname and password and mounts the following shares:

/mnt/root/alg/skripte/Informatik/Fachbereich/C++/CPl
/mnt/scratch
/mnt/<hsruser>
If you need other shares or don't want to have all of these mounted, feel free to adjust the corresponding section within the python script.

To unmount the volumes use sudo umount /mnt/scratch /mnt/root/alg/skripte/Informatik/Fachbereich/C++/CPl /mnt/<hsruser>.

Note
Replace <hsruser> with your real hsr shortname :)


Cevelop on Windows ^

Exercises ^

For all example programs in chapter 0 of Lucid C++ set up the corresponding Cevelop projects and compile and run the programs.

Hello World ^

Create a C++ project (Hello World Executable Project) in Cevelop, compile and run Hello World. This is a sanity check for your enviromant. Please report to your exercise supervisor immediately, if you can not make this work.

Hello World with separate Compilation Unit ^

Hello World Library Project and Unit Test ^

Hello World Class ^

Compiler Errors ^

see also SsW1 pdf

Please try the following variations of the code given and observe if you get compile errors, or if you get interesting results from running the program. Provide your answers on SolW1!

  1. Create a separate empty C++ project that depends on your library class Hello. Add a C++ source file to that new project and use your Hello class there. To be able to compile that file using the library, you need to set in the project's properties->C++ General->Paths and Symbols on the following tabs the corresponding entries (The CUTE Library Project wizard will do that for you):
    • Includes: add to C++ the project Hello as a workspace path
    • Libraries: add "Hello" as the library (-> file will be libHello.a)
    • Library Paths: add "/Hello/Debug" as a workspace path
  2. Remove the declaration of sayHello() from main() in hello1.cpp. What happens when you try to compile it?
  3. Remove the include guard from the header file sayhello.h and include the file twice in the corresponding main program hello.cpp. Do you expect an error? Do you get one? Why?
  4. Perform the same removal of the include guard and double inclusion with the file Hello.h containing the class Hello. Do you expect an error? Do you get one? Why?
  5. What happens when you compile hello.cpp without the implementation file containing the definition of sayHello()? Can you explain the error message?
  6. What happens when you compile hello2.cpp without specifying the library containing the code compiled from sayhello2.cpp?
  7. Since sayHello() is a function, you can call it from itself (sayhello.cpp). What happens if you call it after the output statement? What happens if you call it in front of the output statement? Why does this happen?
    • On Linux or Mac you should limit the stack size using ulimit -s 32 before you run your change program or better run it in a debugger

Common Problems ^


|home |print view |recent changes |changed August 15, 2016 |
exact
|You are 3.95.23.35 <- set your identity!

Ex W1_HS15
go to start