Following these steps will guide you through setting up, troubleshooting, and running AREG SDK on WSL effectively.
- General Information
- Installing a Linux Distribution in WSL
- Troubleshooting WSL Updates
- Installing Build Tools
- Cloning AREG SDK in WSL
- Compiling AREG SDK
- Running Applications
The Windows Subsystem for Linux (WSL) enables users of Windows 10 (version 2004+) and higher to install and use Linux utilities and command-line tools natively. WSL provides access to distributions like Ubuntu and OpenSUSE, removing the need to switch OS environments.
The following sections provide setup, installation, and troubleshooting steps to prepare your WSL environment for building the AREG SDK.
Follow Microsoft's WSL installation guide for complete steps. To install Ubuntu, use:
wsl --install -d ubuntu
After installation, update Ubuntu packages:
sudo apt-get update && sudo apt-get upgrade -y
- Open Command Prompt as Administrator.
- Run:
wsl --set-default-version 2
Experiencing update issues? Common solutions include:
-
Error Code:
Wsl/Service/CreateInstance/0x80040326
Run:wsl --update
-
Network Resolution Issues: DNS issues can cause update failures. You may see errors like
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy/InRelease Temporary failure resolving 'archive.ubuntu.com'
. This can stem from an incorrect DNS in/etc/resolv.conf
. Run following command to check:cat /etc/resolv.conf
If it displays wrong DNS server, like
nameserver 172.23.112.1
, which indicates, for example, the IP-address of your DSL, open/etc/resolv.conf
in the WSL Terminal and change the nameserver to Google DNS. If you're usingvim
, press thei
key to enter insert mode and make the necessary changes:sudo vim /etc/resolv.conf
Update
nameserver
to8.8.8.8
, save the file, and retry the update. If you're usingvim
, press theEsc
key, then type:wq
and pressEnter
.
Alternatively, execute this command in WSL Terminal to set the nameserver in/etc/resolv.conf
:sudo sh -c "echo nameserver 8.8.8.8 > /etc/resolv.conf"
Install the essential tools and libraries to compile AREG SDK:
sudo apt-get install -y git cmake build-essential clang libncurses-dev openjdk-17-jre
You would need additional tools if you want to compile for 32-bit system:
sudo apt-get install -y gcc-multilib g++-multilib
For package specifics, consult your Linux distribution's package list, such as Ubuntu Packages.
Refer to the System Requirements for Linux platforms in the Building AREG SDK with CMake document.
- Create a
projects
directory and navigate to it:mkdir ~/projects && cd ~/projects
- Clone AREG SDK with submodules:
git clone https://github.com/aregtech/areg-sdk.git
- Enter the AREG SDK directory:
cd areg-sdk
Alternatively, navigate to the project path in WSL if already cloned on Windows. For instance, if AREG SDK is located at C:\projects\areg-sdk\
:
cd /mnt/c/projects/areg-sdk/
This section provides example commands for compiling AREG SDK using CMake in different configurations.
To configure and build binaries with the clang++
compiler in Release
mode:
cmake -B ./build -DAREG_COMPILER_FAMILY=llvm -DAREG_BUILD_TYPE=Release
cmake --build ./build -j
To configure and build binaries with the g++
compiler in Debug
mode:
cmake -B ./build -DAREG_COMPILER_FAMILY=gnu -DAREG_BUILD_TYPE=Debug
cmake --build ./build -j
To compile for a 32-bit system, first install the required libraries:
sudo apt-get install -y gcc-multilib g++-multilib
Configure and build binaries with clang++
for a 32-bit system:
cmake -B ./build -DAREG_PROCESSOR=x86 -DAREG_COMPILER_FAMILY=llvm
cmake --build ./build -j
Tip
To verify if an application is compiled for a 32-bit system, navigate to the build binary directory and use:
file ./mcrouter.elf
This command shows the binary's architecture. Example output for a 32-bit mcrouter
binary:
./mcrouter.elf: ELF 32-bit LSB pie executable, Intel 80386, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux.so.2, BuildID[sha1]=3df1d5e3d1b90b9533b93a906cece6ff95fa816c, for GNU/Linux 3.2.0, not stripped
Alternatively, run:
od -t x1 -t c ./mcrouter | head -n 2
Here, the 5th byte of the ELF Header should be 001
for a 32-bit executable and 002
for a 64-bit.
0000000 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
177 E L F 001 001 001 \0 \0 \0 \0 \0 \0 \0 \0 \0
For more details, see the ELF Header documentation.
Important
Troubleshooting: If you encounter a "could not find <asm/errno.h>
" error, resolve it by creating a symbolic link:
sudo ln -s /usr/include/asm-generic/ /usr/include/asm
To compile for a 32-bit ARM system, first install the required toolchain:
sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf
Note
Make sure that gcc-arm-linux-gnueabihf
is better solution than gcc-arm-linux-gnueab
for your device. By default, for ARM processors AREG compiles with gcc-arm-linux-gnueabihf
.
Then configure and build AREG SDK binaries:
cmake -B ./build -DAREG_PROCESSOR=arm -DAREG_COMPILER_FAMILY=gnu
cmake --build ./build -j
Check the binary with file ./mcrouter.elf
. If successful, you'll see output like:
./mcrouter.elf: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux.so.3, BuildID[sha1]=c606ea5ce7be9cb1175fd87587b5975e235c084e, for GNU/Linux 3.2.0, not stripped
To compile for a 64-bit ARM system, install the appropriate toolchain:
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
Then configure and build AREG SDK binaries:
cmake -B ./build -DAREG_PROCESSOR=aarch64 -DAREG_COMPILER_FAMILY=gnu
cmake --build ./build -j
Check the binary with file ./mcrouter.elf
. Successful output will look like:
./mcrouter.elf: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=bcf786a8c893b950868addecbc347d24518a25cd, for GNU/Linux 3.7.0, not stripped
For more information, refer to the AREG SDK Build Guide.
Navigate to the SDK root directory, e.g.,:
cd /mnt/c/projects/areg-sdk/
Run applications located in the bin
directory, such as 10_locservice.elf
:
./product/build/llvm-clang++/linux-64-x86_64-release/bin/10_locservice.elf
Sample output:
A Demo to demonstrate simple request, response, and broadcast ...
"Hello client [ TestServiceClient ]!", remaining [ 36 ] to process.
...
Exit application; check logs for details.
Note
For a list of examples and detailed run instructions, see the README in the AREG SDK examples
directory.