When I built AOSP android-13.0.0_r80 on Ubuntu machine as usual, "libncurses.so.5: cannot open shared object file" stopped build at the beginning of build.

===

repo init -u https://android.googlesource.com/platform/manifest -b android-13.0.0_r84
repo sync
source build/envsetup.sh
lunch sdk_car_x86_64-userdebug
m

Error

FAILED: out/target/product/emulator_car_x86_64/obj/RENDERSCRIPT_BITCODE/libclcore.bc_intermediates/rs_core.bc
/bin/bash -c "PWD=/proc/self/cwd prebuilts/clang/host/linux-x86/clang-3289846/bin/clang -Iframeworks/rs/script_api/include -Iexternal/clang/lib/Headers -MD -DRS_VERSION=24 -std=c99 -c -O3 -
fno-builtin -emit-llvm -target renderscript64-linux-android -fsigned-char -D__x86_64__ -Wno-deprecated -Werror  -Werror -Wall -Wextra -Iframeworks/rs/cpu_ref -DRS_DECLARE_EXPIRED_APIS  -x r
enderscript frameworks/rs/driver/runtime/rs_core.c -o out/target/product/emulator_car_x86_64/obj/RENDERSCRIPT_BITCODE/libclcore.bc_intermediates/rs_core.bc"
prebuilts/clang/host/linux-x86/clang-3289846/bin/clang.real: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory

FAILED: out/target/product/emulator_car_x86_64/obj/RENDERSCRIPT_BITCODE/libclcore.bc_intermediates/rs_allocation.bc                                                                          /bin/bash -c "PWD=/proc/self/cwd prebuilts/clang/host/linux-x86/clang-3289846/bin/clang -Iframeworks/rs/script_api/include -Iexternal/clang/lib/Headers -MD -DRS_VERSION=24 -std=c99 -c -O3 -
fno-builtin -emit-llvm -target renderscript64-linux-android -fsigned-char -D__x86_64__ -Wno-deprecated -Werror  -Werror -Wall -Wextra -Iframeworks/rs/cpu_ref -DRS_DECLARE_EXPIRED_APIS  -x renderscript frameworks/rs/driver/runtime/rs_allocation.c -o out/target/product/emulator_car_x86_64/obj/RENDERSCRIPT_BITCODE/libclcore.bc_intermediates/rs_allocation.bc"
prebuilts/clang/host/linux-x86/clang-3289846/bin/clang.real: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

Resolution

Run following on Ubuntu machine.

sudo ln -s libncurses.so.6 /usr/lib/x86_64-linux-gnu/libncurses.so.5
sudo ln -s libtinfo.so.6 /usr/lib/x86_64-linux-gnu/libtinfo.so.5

Verification is done on following Docker image to avoid contaminating native Ubuntu OS.

FROM ubuntu:20.04

RUN apt update && apt install -y tzdata

# https://source.android.com/docs/setup/start/requirements
RUN apt update && apt install -y  \
    git-core \
    gnupg \
    flex \
    bison \
    build-essential \
    zip \
    curl \
    zlib1g-dev \
    libc6-dev-i386 \
    x11proto-core-dev \
    libx11-dev \
    lib32z1-dev \
    libgl1-mesa-dev \
    libxml2-utils \
    xsltproc \
    unzip \
    fontconfig

RUN apt install -y \
    gawk \
    libncurses5-dev

RUN ln -s libncurses.so.6 /usr/lib/x86_64-linux-gnu/libncurses.so.5
RUN ln -s libtinfo.so.6 /usr/lib/x86_64-linux-gnu/libtinfo.so.5

Reference