How to cross-compile Linux v4l-utils dependency library?
This article will introduce cross-compiling v4l-utils (libv4l) for an aarch64 architecture embedded machine on an x86_64 machine running Ubuntu 20.04 as an example.
-
Install the dependency libraries required to compile v4l-utils.
$ 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
V4l-utilssource code from V4l official website and extract it.
For example, download v4l-utils-1.22.1.tar.bz2 locally.
$ wget https://linuxtv.org/downloads/v4l-utils/v4l-utils-1.22.1.tar.bz2 $ tar xf v4l-utils-1.22.1.tar.bz2 $ cd v4l-utils-1.22.1Then extract the source code through
tarandcdinto the directory.
- If you cannot find "wget", you can install "wget" through
apt install wget. - If "tar" extraction fails, it may be because the system does not have the "bzip2" library installed. You can install it through
apt install bzip2.
-
Generate the configuration file through
./configure.$ ./configure --disable-doxygen-doc --without-jpeg --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)
If you encounter "std" related errors during compilation, it may be because your compiler version is too low. You can try to specify the use of gnu++11 to compile C++ code by executing export CXXFLAGS="-std=gnu++11" before executing the ./configure in step 4.
-
Install v4l-utils to the installation path of the cross-compilation toolchain through
make install, which is the path specified by theprefixparameter in step 4.$ make install
