|
| 1 | ++++ |
| 2 | +date = "2020-05-15T10:46" |
| 3 | +title = "Windows Subsystem for Linux" |
| 4 | +author = "Lars Bilke" |
| 5 | +weight = 1042 |
| 6 | + |
| 7 | +[menu] |
| 8 | + [menu.devguide] |
| 9 | + parent = "advanced" |
| 10 | ++++ |
| 11 | + |
| 12 | +The [Windows Subsystem for Linux](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux) is an alternative way to setup a complete development environment on Windows. It offers a Linux environment with a seamless bridge to the Windows world. We recommend this setup for Windows developers. |
| 13 | + |
| 14 | +## Setup |
| 15 | + |
| 16 | +- Install WSL by following [this guide](https://www.windowscentral.com/install-windows-subsystem-linux-windows-10). **Important:** Choose **Ubuntu 20.04 LTS** as the Linux distribution. Other distros may not have a sufficient compiler. |
| 17 | +- Follow the [developer guide for Linux]({{< ref "prerequisites.pandoc" >}}) from now on. |
| 18 | + |
| 19 | +## Using Visual Studio Code as IDE |
| 20 | + |
| 21 | +You can use the native Windows Visual Studio Code IDE (VS Code) for developing in the WSL. It offers code completion, CMake integration, an integrated debugger, git integration and more. |
| 22 | + |
| 23 | +### Setup |
| 24 | + |
| 25 | +- In the WSL shell run `sudo apt update && sudo apt install -y ninja-build gdb`. |
| 26 | +- On Windows [install Visual Studio Code](https://code.visualstudio.com/docs/setup/windows) |
| 27 | +- Open VS Code and install the [VS Code Remote Development](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) extension |
| 28 | +- In the WSL shell go to your OGS source code and run `code .`. This will open the source code in VS Code. |
| 29 | +- Install the [C/C++](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools), [CMake](https://marketplace.visualstudio.com/items?itemName=twxs.cmake) and [CMake Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools) extensions |
| 30 | + |
| 31 | +### Build and debug OGS |
| 32 | + |
| 33 | +- Configure your project by following [this guide](https://vector-of-bool.github.io/docs/vscode-cmake-tools/getting_started.html#configuring-your-project). Select `GCC 9.3.0` as the [CMake kit](https://vector-of-bool.github.io/docs/vscode-cmake-tools/kits.html#kits). |
| 34 | +- Follow [this guide](https://vector-of-bool.github.io/docs/vscode-cmake-tools/debugging.html#selecting-a-launch-target) for debug a target. Select `ogs` as the debug target. |
| 35 | + |
| 36 | +## Additional notes |
| 37 | + |
| 38 | +The filesystem of the WSL is not inside your regular user directories. You can find it by running `explorer.exe .` inside the WSL shell. It should be something like `\\wsl$\Ubuntu-20.04\home\[username]\...`. |
| 39 | + |
| 40 | +You can also run OGS inside the WSL with benchmarks located in your regular Windows directories. You regular filesystem can be accessed inside WSL with the `/mnt/c/`-prefix. E.g. to run an OGS benchmark: |
| 41 | + |
| 42 | +```bash |
| 43 | +bin/ogs -o _out /mnt/c/Users/[username]/ogs-src/Tests/Data/Elliptic/square_1x1_SteadyStateDiffusion/square_1e0.prj |
| 44 | +``` |
0 commit comments