Remote Desktop (VDI) for Programming C++

Using SFU CS's Virtual Desktop Infrastructure (VDI), you can connect to a CSIL server directly through your web browser and write C++ code using VS Code without having to install anything! It is very easy and convenient! Though I often prefer to have VS Code installed on my own computer for a slightly snappier interface, using the VDI instead is still a first-class experience.

These steps based on this guide made by CS IT staff.

Connect to CSIL VDI

  1. In your web browser, browse to the Web Portal:
    https://bsb-gw-portal.its.sfu.ca/
  2. Authenticate using your SFU Computing ID and password, and the SFU multi-factor authentication code.
  3. Log into the VMWare Horizon portal using:
    Username: your_sfu_computing_id@sfu.ca (note the @sfu.ca is needed) Password: Your SFU password
  4. Select the button for CS-Ubuntu.
  5. Log into the Linux desktop using your SFU computing ID and password (no need for @sfu.ca this time).
    • It may take a minute to log in past the black screen.
    • If prompted to update the operating system, click "Don't Upgrade".

Launch VS Code and Install Extensions

  1. Click "Activities" in the top left corner of the screen.
  2. Type in "Code", and click on the icon for "Visual Studios Code".
  3. Install C/C++ extensions (do once):
    • On the left activity bar, select Extensions
    • Search for "C/C++ Extension Pack"
    • Select "Install"
  4. Create cmpt130 folder on the CSIL server for your course work (do once):
    • We will create a folder on the SFU server to store your code. All your code will be securely stored on the SFU server, so you can connect from any computer to access your files.
    • In VS Code via the VDI, open a terminal by going to the menu at the top (you may need to click the "..."):
      Terminal > New Terminal
    • Change to the folder that is your SFU provided space to save your files:
      cd ~/sfuhome
      • This folder will be available to you on all SFU computers (CSIL labs, CSIL via SSH or VDI, and all SFU computer labs).
      • Other locations under the "~" folder (which is called the "home" folder) are on the CSIL server and would be available only when connected to any CSIL machine.
      • Using ~/sfuhome makes it available on all SFU lab computers (not just CS labs).
    • Make sure that the SFU home folder has correctly "mounted" (become available to use):
      ls
      If you see @_This_IS_NOT_your_real_sfuhome_README.txt, then see troubleshooting below.
    • Create a folder for CMPT 130:
      mkdir cmpt130
      Note: No spaces, suggest keeping all the characters lower-case (but you can pick).
  5. Open the cmpt130 folder:
    • In VS Code, from the menu at the top, select: File > Open Folder...
    • In the window select sfuhome, and then cmpt130.
    • Click Open (top right).
    • If asked "Do you trust the authors of the files in this folder?", select "Yes, I trust the authors".

Write Your Program

  1. Create folder for your work (lab/assignment/...):
    • In the Explorer pane on the left, select the "Create Folder" button at the top.
    • Name the folder based on what you are working on, such as lab1, or lecture_week_2
    • Creating folders for your work helps organize all your files; don't put spaces in the filename
  2. Open/Create file:
    • Right-click on your lab1 folder (or whatever name you gave it) and select "New File"
    • Name the file as needed, such as main.cpp.
    • Click on the file you created to open it.
  3. Code, Build, Debug:
    • Write your C++ code in the file
    • Run your C++ code by either:
      • Above your code, click the Debug C/C++ File button
        (Or, click the drop-down beside it and select to Run C/C++ File)
        If prompted to "Select a debug configuration", choose "C/C++: g++ build and debug active file...". If given multiple options, pick the first one listing "g++" (not "gcc"!)
      • Via the menu at the top select: Run > Start Debugging (or Run Without Debugger)
      • Press F5 (or whatever hotkey File > Start Debugging lists)
  4. Disconnect from the VDI:
    • Once you are finished for the day, disconnect from the CSIL server (it's a shared resource!).
    • Click the power icon in the top right of the Linux desktop and select Log Out.

Submitting Code from Remote VDI Connection

When developing using the SFU Remote VDI connection, your working on the SFU CSIL computers. Since we put your cmpt130 folder under your sfuhome folder, it means all your files are stored on SFU's central file server. This server is backed up and secure!

To submit your code while connected to the SFU Remote VDI, launch a browser inside the VDI connection and browse to your sfuhome/cmpt130/ folder and submit your code. You can also use any SFU computer to access your files!

Troubleshooting

  • If your key-presses when logging in don't match the keys you typed:
    • If you use a different keyboard mapping on your computer (such as Dvorak) note that the Linux desktop won't recognize that during log in. You may need to type the keys native to your keyboard during log-in, and then add a new keyboard configuration to Linux once you have logged in.
  • If your ~/sfuhome folder does not have your files and only has @_This_IS_NOT_your_real_sfuhome_README.txt:
    • If you see this file then it means that the real SFU home folder is not available! Don't use this folder until you resolve the issue, otherwise your files will not be saved.
    • On the SFU network, your home folder exsits on a file server. The CSIL system "mounts" that folder into ~/sfuhome. For some reason, the CSIL server was not able to mount your folder correctly.
    • Try:
      • Close your VS Code, open it again and reconnect.
      • Connect to a different CSIL server (choose a different server number: 01 to 10).
      • Read the file for some things to try:
        cat @_This_IS_NOT_your_real_sfuhome_README.txt
      • Reach out to CS Helpdesk. Let them know your SFU Computing ID, the server you are trying to access, and that you are seeing the @_This_IS_NOT_your_real_sfuhome_README.txt file.