products / solutions
Platform / Framework

How to cross-compile Linux v4l-utils dependency?

Products / Plugins:Video Call / Voice Call

Platform / Framework:Linux

Last updated:2022-07-20 15:47

The following demonstrates cross-compiling v4l-utils (libv4l) on an x86_64 machine with Ubuntu 20.04 for an aarch64 embedded machine.

  1. Install the required libraries for compiling v4l-utils.

    $ 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 V4l-utils source code from V4l official website and unzip it.

    For example, download v4l-utils-1.22.1.tar.bz2 to local.

    $ wget
    $ tar xf v4l-utils-1.22.1.tar.bz2
    $ cd v4l-utils-1.22.1

    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 --disable-doxygen-doc --without-jpeg --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.

    If you encounter "std" related errors when compiling, it may be because your compiler version is outdated, you can try to execute export CXXFLAGS="-std=gnu++11 before executing ./configure in step 4, use gnu++11 to compile the C++ code.

  6. Install v4l-utils 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