FAQ

Products / Plugins
Platform / Framework

How to cross-compile Linux alsa-lib dependency?

Products / Plugins:Video Call / Voice Call

Platform / Framework:Linux

Last updated:2022-07-20 15:47

The following demonstrates cross-compiling alsa-lib (libasound) on an x86_64 machine with Ubuntu 20.04 for an aarch64 embedded machine.

  1. Install the required libraries for compiling alsa-lib.

    $ apt update
    $ apt install make automake libtool
  2. Install the cross-compilation toolchain. The example here installs the latest version of the GNU GCC toolchain. Please install the correct cross-compilation toolchain for your embedded machine according to the actual situation.

    $ apt update
    $ apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
  3. Download the latest version of alsa-lib source code from ALSA official website and unzip 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.2

    Then use tar to unpack the source code, and cd into the unpacked directory.

    If you can't find "wget", you can use "curl" to download the source code. Or install "wget" via apt install wget.

    If the "tar" command fails, the "bzip2" library may not be installed in the system, you can install it through apt install bzip2.

  4. Generate the configuration file via ./configure.

    You can find more information in the official INSTALL documentation

    $ ./configure --enable-shared=yes --enable-static=no --with-pic \
        --host=aarch64-linux-gnu --prefix=/usr/aarch64-linux-gnu

    Use the --host parameter to specify the target for cross-compiling as aarch64-linux-gnu . Note that it may be necessary to modify your cross-compilation target according to your actual situation.

    Use the --prefix parameter to specify the installation path as /usr/aarch64-linux-gnu . Note that it may be necessary to modify the installation path of your cross-compilation toolchain according to your actual situation.

  5. Compile with make.

    $ make -j$(nproc)

    The number of parallel tasks for concurrent compilation can be specified through the -j parameter; you can also compile directly with make.

  6. Install alsa-lib through make install to the installation path of the cross-compilation toolchain, which is the path specified by the prefix parameter in step 4.

    $ make install
Page Directory
Download PDF