User:Aj/Windows Subsystem for Linux
On this page, we cover some basic information about Windows Subsystem for Linux (WSL) when used as a cross-compilation environment. Instructions for setting up the initial cross-compiler on WSL can be found under the article GCC Cross-Compiler and this article assumes that you now have a working GGC compiler for your chosen target architecture in $HOME/opt/cross/bin. The author also uses Ubuntu for WSL, but other options are available through the Windows Store app.
WSL has its own self-contained file system. Although this is theoretically accessible (as a sub-folder in %AppData%), it is strongly recommended that you do not access WSL files from Windows. This is because files edited from Windows do not necessarily update inside the WSL shell.
Instead, you should use the automatic mountpoints within WSL to access files on the native Windows filesystem. For those unfamiliar with Linux, these mountpoints are located under "/mnt/[drive]". For example, the root of "C:\" can be found under "/mnt/c". The command "ln -s" (create symbolic link) may be used to make your chosen project location easily accessible in your home directory.
Suppose an IDE is being used in Windows such as Eclipse, Visual Studio etc... it would be possible to use ln as follows:
ln -s "/mnt/c/Users/[username]/Documents/MyOS" ~/myos
This will create a permanent symlink to your project on your usual Windows filesystem, accessible by typing "cd ~/myos" from your Linux shell. Files will be kept up to date so that your compiler and IDE see the same version of your source files.
It is suggested that you keep your chosen WSL distro up to date by typing:
sudo apt-get update sudo apt-get upgrade
at the Bash shell. This will update the package lists and automatically update any packages that you have installed via "apt-get install x". In addition, you may find the following packages useful as a part of your toolchain:
sudo apt-get install x
where x is:
grub2 - Install GRUB2 including tools such as grub-mkrescue, recommended elsewhere on the wiki for booting your OS. git - Install Git version control. nasm - Install the NASM assembler. xorriso - Used by GRUB2 if you are using ISO images. On testing, grub-mkrescue has been observed to silently fail if this is not installed!
While many other packages can be useful for OS development, many of them will already be installed as requirements of the GCC Cross-Compiler build process.