How to cross-compile Linux alsa-lib dependency library?
This document will introduce how to cross-compile alsa-lib (libasound) for an aarch64 architecture embedded machine on an x86_64 machine with Ubuntu 20.04 as the system.
-
Install the dependency libraries required to compile alsa-lib.
$ apt update $ apt install make automake libtool -
Install the cross-compilation toolchain.
This example installs the latest version of the GNU GCC toolchain. Please install the correct cross-compilation toolchain for your embedded machine according to your actual situation.
$ apt update
$ apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu-
Download the latest version of
alsa-libsource code from ALSA Official Website and extract it.
For example, download alsa-lib-1.2.7.2.tar.bz2 to local.
$ wget https://www.alsa-project.org/files/pub/lib/alsa-lib-1.2.7.2.tar.bz2 $ tar xf alsa-lib-1.2.7.2.tar.bz2 $ cd alsa-lib-1.2.7.2Then use
tarto extract the source code andcdinto the extracted directory.
- If you cannot find "wget", you can install "wget" through
apt install wget. - If "tar" extraction fails, it may be that the system does not have the "bzip2" library installed. You can install it through
apt install bzip2.
-
Generate the configuration file through
./configure.$ ./configure --enable-shared=yes --enable-static=no --with-pic \ --host=aarch64-linux-gnu --prefix=/usr/aarch64-linux-gnu- Specify the cross-compilation target as
aarch64-linux-gnuthrough the--hostparameter. You need to modify this according to your actual situation to your cross-compilation target. - Specify the installation path as
/usr/aarch64-linux-gnuthrough the--prefixparameter. You need to modify this according to your actual situation to the installation path of your cross-compilation toolchain.
- Specify the cross-compilation target as
-
Specify the number of parallel tasks for concurrent compilation through the
-jparameter, or compile directly throughmake.$ make -j$(nproc) -
Install alsa-lib to the installation path of the cross-compilation toolchain through
make install, which is the path specified by theprefixparameter in step 4.$ make install
