D84 Windows Setup

D84 Windows Setup

Hello D84-ers! This is a quick tutorial of how to set up your Windows machine to be able to run your assignments. If anything doesn’t work, or something is confusing to you, please let me know so I can improve it for the next person!

If you have already set up an Ubuntu WSL on your Windows machine, you can skip down to Part 2.

Note that there are many possible ways to set up your environment, and this only covers one of them.

Part 1: Setting up WSL (Windows Subsystem for Linux)

Note that for WSL, you must have a 64-bit OS. I have also seen issues where WSL could not be installed on certain laptops bought in China, so try the steps below but you may need to use some other method to set up your computer.

  1. From the search bar, search for and open “Turn Windows Features On or Off”
  2. At the bottom, make sure “Windows Subsystem for Linux” is checked.
  3. Click OK, it should begin downloading and may ask you to restart
  4. After restarting, open up the Windows Store and download (and open!) the “Ubuntu” app
    1. Note: Shouldn’t matter which version of Ubuntu you download
  5. Once opened, it will take a while to install. If it takes longer than 40 minutes, start hitting a key every once in a while to help it realize it’s done.
  6. Follow the prompts to create a UNIX user account. Your password will be asked for whenever you use sudo
  7. To check that everything is working properly:
    1. Open Windows Command Prompt (can type cmd from the search bar)
    2. In the command prompt, type in bash and hit enter, this should open up your Linux terminal in the same folder that command prompt was opened in, and should see something like user@DESKTOP-JDLSD30:/mnt/c/whatever/folder/you/were/in$ as the new prompt.

Part 2: Setting up the Compiler and Packages

  1. Open Windows Command Prompt and type in bash to enter Ubuntu
  2. Enter sudo apt-get update
  3. Enter sudo apt-get install build-essential freeglut3-dev libgl1-mesa-dev libglu1-mesa-dev
  4. Check that the required compilers have been installed by running:
    1. gcc --version
      Example output should look something like
      gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
      with lots more after it
    2. g++ --version
      Example output should look something like
      g++ (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
      with lots more after it

Part 3: Setting up OpenGL

  1. Download and install Xming X Server. You can set it up however you want as long as you install both Xming and XLaunch.
  2. Open your bash terminal
  3. Enter export DISPLAY=:0 this will have to be run whenever you have opened a new bash terminal and are planning on running an assignment
  4. Note that you do not need to do anything else for Xming to set it up

Part 4: Test Your Setup!

  1. Download this script and save it in your (nicely filed!) CSCD84 class folder
  2. Open your class folder in the bash terminal
  3. (Don’t forget to run export DISPLAY=:0 if this is a newly opened bash terminal)
  4. Compile with gcc d84_setup_test.c -lm -lglut -lGL -lGLU -o d84_setup_test
  5. Run with ./d84_setup_test
  6. If no window pops up, something went wrong. Make sure you set the DISPLAY value on this terminal and retrace the steps on this page. Additionally, see Part 5.

That’s it! You’re set up to run D84 assignments! Good luck!

Part 5: Issues…

If you get the error Failed to open display ':0' or Failed to open display '', a couple more steps may be required:

  1. In the bash terminal, enter sudo nano ~/.bashrc
  2. In the file that appears, at the very bottom, either add or change export DISPLAY=0 to export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0.0
  3. At the bottom right of the windows taskbar, close Xming by clicking on the up (^) arrow, right clicking on the X icon, and exiting it.
  4. Search Windows for XLaunch, continue regular setup, but check off “No Access Control” on the 3rd page.
  5. Rerun the test script in a new bash terminal (WITHOUT setting DISPLAY in the terminal again)
  6. If you’re still getting errors, carefully repeat steps 3-5.

It should hopefully work now! And if you run these steps, you won’t need to run DISPLAY=:0 each time you open a new shell.

Share:
Author face

Nyah Way

Computer science specialist and the University of Toronto alumni, now pursuing her full-time career at Google.

Things I've worked on: