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.
- From the search bar, search for and open “Turn Windows Features On or Off”
- At the bottom, make sure “Windows Subsystem for Linux” is checked.
- Click OK, it should begin downloading and may ask you to restart
- After restarting, open up the Windows Store and download (and open!) the “Ubuntu” app
- Note: Shouldn’t matter which version of Ubuntu you download
- 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.
- Follow the prompts to create a UNIX user account. Your password will be asked for whenever you use
sudo
- To check that everything is working properly:
- Open Windows Command Prompt (can type
cmd
from the search bar) - 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 likeuser@DESKTOP-JDLSD30:/mnt/c/whatever/folder/you/were/in$
as the new prompt.
- Open Windows Command Prompt (can type
Part 2: Setting up the Compiler and Packages
- Open Windows Command Prompt and type in
bash
to enter Ubuntu - Enter
sudo apt-get update
- Enter
sudo apt-get install build-essential freeglut3-dev libgl1-mesa-dev libglu1-mesa-dev
- Check that the required compilers have been installed by running:
gcc --version
Example output should look something likegcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
with lots more after itg++ --version
Example output should look something likeg++ (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
with lots more after it
Part 3: Setting up OpenGL
- Download and install Xming X Server. You can set it up however you want as long as you install both Xming and XLaunch.
- Open your
bash
terminal - Enter
export DISPLAY=:0
this will have to be run whenever you have opened a newbash
terminal and are planning on running an assignment - Note that you do not need to do anything else for Xming to set it up
Part 4: Test Your Setup!
- Download this script and save it in your (nicely filed!) CSCD84 class folder
- Open your class folder in the
bash
terminal - (Don’t forget to run
export DISPLAY=:0
if this is a newly openedbash
terminal) - Compile with
gcc d84_setup_test.c -lm -lglut -lGL -lGLU -o d84_setup_test
- Run with
./d84_setup_test
- 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:
- In the bash terminal, enter
sudo nano ~/.bashrc
- In the file that appears, at the very bottom, either add or change
export DISPLAY=0
toexport DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0.0
- 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.
- Search Windows for XLaunch, continue regular setup, but check off “No Access Control” on the 3rd page.
- Rerun the test script in a new bash terminal (WITHOUT setting DISPLAY in the terminal again)
- 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.