\label{doc_tutorials_contributing-windows_md_md_doc_tutorials_contributing_windows}%
\Hypertarget{doc_tutorials_contributing-windows_md_md_doc_tutorials_contributing_windows}%
 In this tutorial, you will learn how to set up a development environment for Elektra using Windows Subsystem for Linux (WSL) and Visual Studio 2019.

Visual Studio 2019 (VS2019) Community is free but requires a registration after a couple of days. \href{https://visualstudio.microsoft.com/downloads/}{\texttt{ Download it}} and install the Linux development with C++ workload.

Elektra development mainly happens on GNU/\+Linux distributions. Therefore, it makes sense to use WSL if you have Windows 10 installed on your PC. For the beginning, it does not matter if you choose WSL 1 or WSL 2. It is possible to convert them later.\hypertarget{doc_tutorials_contributing-windows_md_autotoc_md3564}{}\doxysection{Download and Installation}\label{doc_tutorials_contributing-windows_md_autotoc_md3564}
We assume you use Ubuntu as WSL distribution. Install the packages required for building from VS2019\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{apt install g++ gdb make ninja-\/build rsync zip}

\end{DoxyCode}


Then clone the libelektra git repository\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{git clone git@github.com:ElektraInitiative/libelektra.git}

\end{DoxyCode}


\begin{quote}
{\bfseries{Do not use VS2019 to clone the repository}}\+: You will not be able to compile because of invalid line endings. \end{quote}
and open it in VS2019. It will complain that Intelli\+Sense is out of date. In addition, the {\ttfamily Error List} at the bottom will show CMake errors about missing compilers. To solve this, you have to configure a Linux CMake project.\hypertarget{doc_tutorials_contributing-windows_md_autotoc_md3565}{}\doxysection{Configure a Linux CMake project}\label{doc_tutorials_contributing-windows_md_autotoc_md3565}
Microsoft has \href{https://docs.microsoft.com/en-us/cpp/linux/cmake-linux-configure?view=msvc-160}{\texttt{ even more information}} about this task.

In the drop-\/down menu that says {\ttfamily x64-\/\+Debug (Default)} click {\ttfamily Manage Configurations...}. Add {\ttfamily WSL-\/\+GCC-\/\+Debug} and save the configuration.

\begin{quote}
You can remove {\ttfamily x64-\/\+Debug (Default)}. \end{quote}
CMake generation will automatically restart. When it has completed, you can click the drop-\/down {\ttfamily Select Startup Item...} (by the green {\itshape Play} button).

A long list of targets should appear. Choose {\ttfamily hello (bin\textbackslash{}hello)} and click the green {\itshape Play} button. You should now see the output {\ttfamily Hello world} in the Linux Console Window at the bottom.\hypertarget{doc_tutorials_contributing-windows_md_autotoc_md3566}{}\doxysection{Why choose VS2019}\label{doc_tutorials_contributing-windows_md_autotoc_md3566}
One advantage of using VS2019 is the graphical debugger. Search for {\ttfamily hello.\+c} in the Solution Explorer to the right. Create a breakpoint in the main function and run the program again using the green {\itshape Play} button.

On the bottom-\/left you will see the windows {\ttfamily Autos}, {\ttfamily Locals} and {\ttfamily Watch 1}. Click on {\ttfamily Locals} to inspect the {\ttfamily Key $\ast$ k}. Right-\/click {\ttfamily key\+New} to access functions like {\ttfamily Peek Definition}.\hypertarget{doc_tutorials_contributing-windows_md_autotoc_md3567}{}\doxysection{Choosing your WSL version}\label{doc_tutorials_contributing-windows_md_autotoc_md3567}
It makes sense to compare WSL 1 and WSL 2 and make an informed decision for one of them. Your setup may require adaptions, such as installing an SSH server in your Linux distribution.

Good sources of information are\+:


\begin{DoxyItemize}
\item the article \href{https://docs.microsoft.com/en-us/windows/wsl/compare-versions}{\texttt{ Comparing WSL 1 and WSL 2}} from the official WSL documentation
\item the blog post \href{https://devblogs.microsoft.com/cppblog/c-with-visual-studio-and-wsl2/}{\texttt{ C++ with Visual Studio and WSL2}}
\item the official \href{https://docs.microsoft.com/en-us/cpp/linux/?view=msvc-160}{\texttt{ Linux with Visual Studio C++ documentation}}
\end{DoxyItemize}

Commands to change your WSL version can be found, for example, in the blog post \href{https://devblogs.microsoft.com/commandline/wsl-2-is-now-available-in-windows-insiders/}{\texttt{ WSL 2 is now available in Windows Insiders}}\hypertarget{doc_tutorials_contributing-windows_md_autotoc_md3568}{}\doxysection{Troubleshooting}\label{doc_tutorials_contributing-windows_md_autotoc_md3568}
For further information, consider the official \href{https://docs.microsoft.com/en-us/cpp/linux/?view=msvc-160}{\texttt{ Linux with Visual Studio C++ documentation}}.

If you choose to work with source code residing on a Windows filesystem mounted in WSL (e.\+g.{\ttfamily /mnt/c/...}), please enable the {\ttfamily metadata} option to prevent problems due to permissions not being persisted\+:


\begin{DoxyItemize}
\item Create or modify {\ttfamily /etc/wsl.conf} to contain the following section and setting\+:
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{[automount]}
\DoxyCodeLine{options = "{}metadata"{}}

\end{DoxyCode}



\begin{DoxyItemize}
\item Restart the WSL VM by issuing {\ttfamily wsl -\/-\/shutdown} in your window console.
\end{DoxyItemize}

Building from sources residing on a mounted windows file system may incur a signifcant performance penalty. Consider using your WSL home directory (e.\+g. {\ttfamily $\sim$/}) as your location for the Elektra sources. 