From 143cdf4b5c27a9cd2b7acdc9f5c6f94c768e5911 Mon Sep 17 00:00:00 2001 From: jmacey Date: Fri, 16 Jun 2023 14:15:45 +0100 Subject: [PATCH] finished WSL writeup --- WSL.md | 231 ++++++++++++++++++++++++++------------------------------- 1 file changed, 104 insertions(+), 127 deletions(-) diff --git a/WSL.md b/WSL.md index 267f8880..d7f56c19 100644 --- a/WSL.md +++ b/WSL.md @@ -1,136 +1,113 @@ # Installing NGL under WSL -First follow the steps to install WSLg or go to the app store and install the Ubuntu 22.04.2 LTS app. +WSL is the Windows Subsystem for Linux, it allows you to run a Linux environment under Windows 10 / 11. It will allow you to run the NGL demos in a very similar way to the lab environment. This can somethings be easier than setting up under native windows. + +Whilst there are a number of linux distributions available for WSL I have only tested with Ubuntu 22.04.2 LTS as this has the simplest out of the box installation for GPU and other tools. I strongly recommend you use this version. You will also need the correct drivers (I test with nVidia game drivers which support accelerated GPU under wsl) +## Installing WSL + +First follow the steps to install WSLg or go to the app store and install the Ubuntu 22.04.2 LTS app. More details can be found here https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps + +![WSL](images/Ubuntu.png) + + +Once the initial setup has been done (adding a user and password), we need to install some base packages in the terminal. It is also suggested that VSCode is installed in Windows and the Remote WSL extension is installed. This will allow you to edit and run code in the WSL environment. + +```bash +suso apt-get update +sudo apt install -y build-essential wget vim cmake ninja-build +sudo apt install -y libgl-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev +sudo apt install -y git curl zip unzip tar pkg-config python3 pip +sudo apt install libxinerama-dev libxcursor-dev xorg-dev libglu1-mesa-dev pkg-config +sudo apt install mesa-utils freeglut3-dev mesa-common-dev +sudo apt install libqt6opengl6-dev +``` + +This will install all of the base packages needed to build NGL and run the demos. + +## Installing vcpkg + +The vcpkg install is the same as usual, to start with we will only install the core libraries we need to run the NGL demos, you may also need to install other packages later. + +```bash +git clone https://github.com/Microsoft/vcpkg.git ~/vcpkg +cd ~/vcpkg +./bootstrap-vcpkg.sh +./vcpkg install install gtest glm gl3w glfw3 rapidjson rapidxml fmt freetype openimageio +``` + +This may take some time to build, grab a coffee and come back later. + +## Installing NGL + +We can clone the NGL repository usually you will only need the head of the repo not the full history so we can use the `--depth 1` flag to only get the latest version. + +```bash +git clone --depth 1 https://github.com:/NCCA/NGL ~/NGLBuild +cd ~/NGLBuild/ +cmake -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_INSTALL_PREFIX=~/NGL -G Ninja -B build -S . +cd build +cmake --build . +./NGLTests +``` + +This should build all the NGL library and Unit tests, if you get any errors please check the output and make sure you have installed all the packages above. + +We can now install NGL using + +```bash +cmake --build . --target install +``` + +## SimpleNGL demo + +We can now build the SimpleNGL demo, this is a simple demo that shows how to use NGL to draw a simple teapot. + +``` +git clone https://github.com:/NCCA/SimpleNGL +cd SimpleNGL/ +mkdir build +cd build/ +cmake -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake -G Ninja -DCMAKE_PREFIX_PATH=~/NGL .. +cmake --build . +./SimpleNGL +``` + +![SimpleNGL](images/wsl2.png) + + +## SDLNGL + +The SDLNGL demo requires the SDL2 libraries to be installed, you can do this with vcpkg +```bash +cd ~/vcpkg +./vcpkg install sdl2 sdl2-image +``` + +Now we can clone and build the demo + +``` +git clone https://github.com:/NCCA/SDLNGL ~/SDLNGL +cd ~/SDLNGL/ +mkdir build +cd build/ +cmake -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake -G Ninja .. +cmake --build . +./SDLNGL +``` + +#![SDLNGL](images/wsl1.png) + +## Environment variables +To make life easier we can add the following environment variables into our .bashrc file, this will allow us to run the demos without having to set the LD_LIBRARY_PATH and other variables each time. +```bash +export CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH:~/NGL +export CMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake +``` +once this is added (you should be able to type code ~/.bashrc if VSCode is installed) you can reload the file with `source ~/.bashrc` and then build the demos without having to set the environment variables each time. - - 4 sudo apt-get update && sudo apt install -y build-essential wget vim cmake ninja-build && apt install -y libgl-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev && apt install -y git curl zip unzip tar pkg-config python3 - 5 sudo apt-get apt install -y git curl zip unzip tar pkg-config python3 - 6 sudo apt-get install -y git curl zip unzip tar pkg-config python3 - 7 git clone https://github.com/Microsoft/vcpkg.git ~/vcpkg && cd ~/vcpkg && ./bootstrap-vcpkg.sh - 8 ./vcpkg install install gtest glm gl3w glfw3 rapidjson rapidxml fmt freetype openimageio - 9 ./vcpkg install gtest glm gl3w glfw3 rapidjson rapidxml fmt freetype openimageio - 10 ./vcpkg install gl3w - 11 code /home/jmacey/vcpkg/buildtrees/gl3w/config-x64-linux-out.log - 12 sudo apt-get install -y mesa-devel - 13 apt search mesa - 14 apt search mesa-gl - 15 sudo apt install mesa-utils libglu1-mesa-dev freeglut3-dev mesa-common-dev - 16 ./vcpkg install gl3w - 17 ./vcpkg install install gtest glm gl3w glfw3 rapidjson rapidxml fmt freetype openimageio - 18 ./vcpkg install gtest glm gl3w glfw3 rapidjson rapidxml fmt freetype openimageio - 19 sudo apt install libxinerama-dev libxcursor-dev xorg-dev libglu1-mesa-dev pkg-config - 20 ./vcpkg install gtest glm gl3w glfw3 rapidjson rapidxml fmt freetype openimageio - 21 cd .. - 22 ls - 23 git clone --depth 1 https://github.com:/NCCA/NGL ~/NGLBuild && cd ~/NGLBuild/ && cmake -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake -G Ninja -B build -S . &&cd build && cmake --build . - 24 ./NGLTests - 25 cd .. - 26 cd - 27 ls - 28 cd vcpkg/ - 29 ./vcpkg install sdl2 sdl2_image - 30 ./vcpkg install sdl2 sdl2-image - 31 cd - 32 git clone https://github.com:/NCCA/SDLNGL - 33 cd SDLNGL/ - 34 # cmake -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake -G Ninja -B build -S . &&cd build && cmake --build . - 35 mkdir build - 36 cd build/ - 37 ls - 38 # cmake -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake -G Ninja .. - 39 ls - 40 cmake -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake -G Ninja .. - 41 cmake --build . - 42 cd . - 43 cd .. - 44 ls - 45 ccd .. - 46 lcd .. - 47 ls - 48 cd .. - 49 cd NGLBuild/ - 50 cd build/ - 51 ls - 52 cmake -DCMAKE_INSTALL_PREFIX= - 53 cmake -DCMAKE_INSTALL_PREFIX=~/NGL .. - 54 make install - 55 cmake --build . --target install - 56 cd - 57 cd SDLNGL/ - 58 cd build/ - 59 cmake -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake -G Ninja .. - 60 rm CMakeCache.txt - 61 cmake -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake -G Ninja -DCMAKE_PREFIX_PATH=~/NGL .. - 62 cmake --build . --target install - 63 cmake --build . - 64 ls - 65 ./SDLNGL - 66 cd - 67 history - 68 history &>WSL.md - 69 cd - 70 cd vcpkg/ - 71 ls - 72* - 73 ./vcpkg search Qt6 - 74 ./vcpkg search qt6 - 75 ./vcpkg search qt - 76 ./vcpkg install qtbase[opengl] - 77 code /home/jmacey/vcpkg/buildtrees/fontconfig/config-x64-linux-dbg-out.log' - 78 code /home/jmacey/vcpkg/buildtrees/fontconfig/config-x64-linux-dbg-out.log - 79 python3 - 80 python - 81 ls - 82 alias python='python3' - 83 python - 84 ./vcpkg install qtbase[opengl] - 85 code /home/jmacey/vcpkg/buildtrees/fontconfig/x64-linux-dbg/meson-logs/meson-log.txt - 86 python3 -m pip install distutils - 87 python3 -m pip3 install distutils - 88 pip - 89 /usr/bin/python3 -m pip3 install distutils - 90 cd - 91 ls - 92 pwd - 93 ls -al - 94 python - 95 apt install pip - 96 sudo apt install pip - 97 cd vcpkg/ - 98 ./vcpkg install qtbase[opengl] - 99 ./vcpkg install icu - 100 apt search Qt - 101 /home/jmacey/vcpkg/buildtrees/fontconfig/x64-linux-dbg/meson-logs/meson-log.txt - 102 sudo apt-get install qt5-default - 103 sudo apt-get install qt5 - 104 apt search Qt6 - 105 apt search rg - 106 apt search rip - 107 apt search ripgrep - 108 sudo apt install ripgrep - 109 apt search Qt6 | rg base - 110 apt search Qt6 | rg default - 111 apt search Qt6 | rg devel - 112 apt search Qt6 - 113 apt search Qt6 | rg opengl - 114 sudo apt install libqt6opengl6-dev - 115 cd - 116 git clone https://github.com:/NCCA/SimpleNGL - 117 cd SimpleNGL/ - 118 ls - 119 mkdir build - 120 cd build/ - 121 history | rg cmake - 122 cmake -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake -G Ninja -DCMAKE_PREFIX_PATH=~/NGL .. - 123 cmake --build . - 124 ./SimpleNGL - 125 history | rg cmake - 126 cd - 127 ls - 128 history &>WSL.md