\label{doc_tutorials_hello-elektra_md_md_doc_tutorials_hello_elektra}%
\Hypertarget{doc_tutorials_hello-elektra_md_md_doc_tutorials_hello_elektra}%
 This basic tutorial shows you how to compile and run a very basic Elektra application. For this tutorial we assume that you installed \mbox{\hyperlink{doc_INSTALL_md}{Elektra}} and \href{https://cmake.org}{\texttt{ CMake}} on your machine. We also assume that you work a Unix based OS like Linux or mac\+OS.


\begin{DoxyEnumerate}
\item Create a folder called {\ttfamily Hello} somewhere on your disk
\item Copy the file {\ttfamily examples/hello\+Elektra.\+c} to the folder {\ttfamily Hello} you just created
\item Save a file with the following content
\end{DoxyEnumerate}


\begin{DoxyCode}{0}
\DoxyCodeLine{cmake\_minimum\_required(VERSION 3.0)}
\DoxyCodeLine{}
\DoxyCodeLine{find\_package(Elektra REQUIRED)}
\DoxyCodeLine{}
\DoxyCodeLine{if (ELEKTRA\_FOUND)}
\DoxyCodeLine{    message (STATUS "{}Elektra \$\{ELEKTRA\_VERSION\} found"{})}
\DoxyCodeLine{    include\_directories (\$\{ELEKTRA\_INCLUDE\_DIR\})}
\DoxyCodeLine{}
\DoxyCodeLine{    add\_executable (hello helloElektra.c)}
\DoxyCodeLine{    target\_link\_libraries (hello \$\{ELEKTRA\_LIBRARIES\})}
\DoxyCodeLine{else (ELEKTRA\_FOUND)}
\DoxyCodeLine{    message (FATAL\_ERROR "{}Elektra not found"{})}
\DoxyCodeLine{endif (ELEKTRA\_FOUND)}

\end{DoxyCode}


as {\ttfamily CMake\+Lists.\+txt} in the folder {\ttfamily Hello}.


\begin{DoxyEnumerate}
\item Open a shell and change into the directory {\ttfamily Hello}
\item Create a build directory inside {\ttfamily Hello}, change into the build directory, and run Cmake\+:
\end{DoxyEnumerate}


\begin{DoxyCode}{0}
\DoxyCodeLine{mkdir build}
\DoxyCodeLine{cd build}
\DoxyCodeLine{cmake ..}

\end{DoxyCode}


. If everything worked until now, then CMake should print messages that look something like this\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{-\/-\/ The C compiler identification is Clang 12.0.0}
\DoxyCodeLine{-\/-\/ The CXX compiler identification is Clang 12.0.0}
\DoxyCodeLine{-\/-\/ Check for working C compiler: usr/bin/cc}
\DoxyCodeLine{-\/-\/ Check for working C compiler: usr/bin/cc -\/-\/ works}
\DoxyCodeLine{-\/-\/ Detecting C compiler ABI info}
\DoxyCodeLine{-\/-\/ Detecting C compiler ABI info -\/ done}
\DoxyCodeLine{-\/-\/ Detecting C compile features}
\DoxyCodeLine{-\/-\/ Detecting C compile features -\/ done}
\DoxyCodeLine{-\/-\/ Check for working CXX compiler: usr/bin/c++}
\DoxyCodeLine{-\/-\/ Check for working CXX compiler: usr/bin/c++ -\/-\/ works}
\DoxyCodeLine{-\/-\/ Detecting CXX compiler ABI info}
\DoxyCodeLine{-\/-\/ Detecting CXX compiler ABI info -\/ done}
\DoxyCodeLine{-\/-\/ Detecting CXX compile features}
\DoxyCodeLine{-\/-\/ Detecting CXX compile features -\/ done}
\DoxyCodeLine{-\/-\/ Elektra 0.9.7 found}
\DoxyCodeLine{-\/-\/ Configuring done}
\DoxyCodeLine{-\/-\/ Generating done}
\DoxyCodeLine{-\/-\/ Build files have been written to: Hello/build}

\end{DoxyCode}



\begin{DoxyEnumerate}
\item Now it’s time to build your application. For that step run {\ttfamily make} inside the folder {\ttfamily Hello/build}\+:
\end{DoxyEnumerate}


\begin{DoxyCode}{0}
\DoxyCodeLine{make}

\end{DoxyCode}


. If the last step completed successfully, then the build directory now contains the application {\ttfamily hello}.


\begin{DoxyEnumerate}
\item You can now run your Elektra application by calling {\ttfamily ./hello} inside the build directory. The output of the application should look something like this\+:
\end{DoxyEnumerate}


\begin{DoxyCode}{0}
\DoxyCodeLine{Open key database}
\DoxyCodeLine{Retrieve key set}
\DoxyCodeLine{Number of key-\/value pairs: 0}
\DoxyCodeLine{Add key user:/test/hello}
\DoxyCodeLine{Number of key-\/value pairs: 1}
\DoxyCodeLine{}
\DoxyCodeLine{hello, elektra}
\DoxyCodeLine{}
\DoxyCodeLine{Delete key-\/value pairs inside memory}
\DoxyCodeLine{Close key database}

\end{DoxyCode}



\begin{DoxyEnumerate}
\item You can now change the content of {\ttfamily hello\+Elektra.\+c}. If you want to compile and execute the updated code, then repeat steps 6 and 7. 
\end{DoxyEnumerate}