One of the platform compilations: cross-compilation of plugins such as OpenCV and FFmpeg on the ZYNQ platform

Source: Internet
Author: User
Tags bz2 git clone

One: the preparatory work

Project Version number Link
Operating system Ubuntu 16.04
OpenCV 2.4.13 3.2.0 Opencv-2.4.13.zip
Ffmpeg 3.1.4 ffmpeg-3.1.4.tar.bz2
x264 20161020 x264-snapshot-20161019-2245-stable.tar.bz2
Libjpeg 9.0.0 Jpegsrc.v9.tar.gz
Libpng 1.6.25 Libpng-1.6.25.tar.gz
Xvidcore 1.3.4 Xvidcore-1.3.4.tar.gz

1.1 Install dependent libraries:

Because it's going to run on Zedboard, installing Xilinx's cross-compilation tool can be downloaded from github or I can download it from here, because this tool is designed for 32-bit systems, and 64-bit systems need to install some 32-bit libraries first

sudo apt-get install libc6:i386 libx11-6:i386 libasound2:i386 libatk1.0-0:i386 libcairo2:i386 libcups2:i386 libdbus-glib-1-2:i386 libgconf-2-4:i386 libgdk-pixbuf2.0-0:i386 libgtk-3-0:i386 libice6:i386 libncurses5:i386 LIBSM6 : i386 liborbit2:i386 libudev1:i386 libusb-0.1-4:i386 libstdc++6:i386 libxt6:i386 libxtst6:i386 libgnomeui-0:i386 Libusb-1.0-0-dev:i386 libcanberra-gtk-module:i386 gtk2-engines-murrine:i386
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 libgtk2.0-0:i386

Then change dash to bash

sudo dpkg-reconfigure Dash

Select No in the pop-up dialog box, change dash to bash, and then modify permissions for the installer

1.2: Set Environment variables:

Export Arch=arm export
cross_compile=arm-xilinx-linux-gnueabi-
export Path=/opt/xilinx/sdk/2016.4/gnu/arm /lin/bin/: $PATH export
zynq_cv_build=/opt/opencv3 export
cc=arm-xilinx-linux-gnueabi-gcc

Export ldflags= "-l/opt/opencv3/lib"
export cppflags= "-i/opt/opencv3/include"

export pkg_config_path= $PKG _config _path:/opt/opencv3/lib/pkgconfig
Export Ldflags=-wl,-rpath-link,/opt/opencv3/lib

Two: cross-compiling plug-ins

2.1 libjpeg cross-compiling

This will need to be configured first to compile and install in the later dependent libraries

TAR-XZVF jpegsrc.v9.tar.gz
cd jpeg-9
./configure--host=arm-xilinx-linux CC=ARM-XILINX-LINUX-GNUEABI-GCC --prefix=<dependency install path> make make and
install

You can specify the location where the compiled library will be installed at the time of configuration, or install it directly in "/usr/local/lib" using "sudo make install", similar to the following installation method.
You can switch to the folder under installation to see if cross-compilation is successful

File libjpeg.so.9.0.0

If the output information is

Libjpeg.so.9.0.0:elf 32-bit LSB  Shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, not stripped

Description Cross Compilation successful 2.2 zlib cross compilation

Zlib need to pre-specify CC options

Export CC=ARM-XILINX-LINUX-GNUEABI-GCC
./configure--shared--prefix=<dependency install path>
make Make
Install
2.3 libpng cross-compiling

Because libpng cross-compiling requires zlib, you need to cross-compile the library before compiling it zlib

Export ldflags= "-l<zlib install Path>/lib"
export cppflags= "-i<zlib install Path>/inclue"
. Configure--host=arm-xilinx-linux cc=arm-xilinx-linux-gnueabi-gcc--prefix=<dependency install path>

Before compiling, you need to specify the installation path and header file location of the Zlib library, if the above paths are installed with administrator rights, respectively,

Export ldflags= "-l/usr/local/lib"
export cppflags= "-i/usr/local/include"
2.4 x264 cross-compiling
TAR-XVF x264-snapshot-20161019-2245-stable.tar
cd x264-snapshot-20161019-2245-stable/
./configure--host= Arm-xilinx-linux--cross-prefix=arm-xilinx-linux-gnueabi---disable-asm--enable-shared--prefix=<dependency Install path> make make
install
2.5 Xvidcore cross-compiling

Xvidcore configuration file in/build/generic

CD build/generic
./configure--host=arm-xilinx-linux-gnueabi--disable-assembly--enable-shared--prefix=< Dependency install path> make make and
install
2.6 FFmpeg Cross-compiling
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
./configure--enable-shared--disable-static-- cross-prefix=arm-xilinx-linux-gnueabi- 
--arch=arm--target-os=linux--disable-stripping-- Enable-cross-compile--disable-asm 
--enable-libxvid--enable-libx264--ENABLE-GPL 
--extra-cflags=-I< Dependency Install path>/include--extra-ldflags=-l<dependency Install Path>/lib--prefix=<dependency Install path> make make
install

The script is used here directly

echo "/n/n===================== 1 libjpeg Cross compilation =======================" Sleep 3 tar zxvf jpegsrc.v9.tar.gz cd jpeg-9./con


Figure--prefix= $ZYNQ _cv_build--host=arm-xilinx-linux-gnueabi--enable-shared make make install CD.
echo "/n/n===================== 2 zlib Cross compilation =======================" Sleep 3 tar zxvf zlib-1.2.11.tar.gz CD zlib-1.2.11/


./configure--prefix= $ZYNQ _cv_build--shared make do install CD. echo "/n/n===================== 3 libpng Cross compilation =======================" Sleep 3 tar zxvf libpng-1.6.32.tar.gz CD libpng-1.6 ./configure--prefix= $ZYNQ _cv_build--host=arm-xilinx-linux-gnueabi--with-pkgconfigdir= $ZYNQ _cv_build/lib/



Pkgconfig ldflags=-l$zynq_cv_build/lib cflags=-i$zynq_cv_build/include make do install CD. echo "\n\n===================== 4 x264 Cross compilation =======================" Sleep 3 tar jxvf X264-SNAPSHOT-20161019-2245-STABLE.TAR.BZ2 CD x264-snapshot-20161019-2245-stable./configure--host=arm-linux-- cross-prefix=arm-xilinx-linux-gnueabi---enable-sharEd--prefix= $ZYNQ _cv_build make do install CD. echo "\n\n===================== 5 xvidcore Cross compilation =======================" Sleep 3 tar zxvf xvidcore-1.3.4.tar.gz CD Xvidcor e/build/generic/./configure--prefix= $ZYNQ _cv_build--host=arm-xilinx-linux-gnueabi--disable-assembly-- enable-shared make make-install CD. /.. /.. /echo "\n\n===================== 6 FFmpeg Cross compilation =======================" Sleep 3 tar jxvf ffmpeg-0.10.16.tar.bz2 CD Ffmpe g-0.10.16 ls./configure--prefix= $ZYNQ _cv_build--enable-shared--disable-static--ENABLE-GPL--enable-cross-compile --arch=arm--disable-stripping--target-os=linux--enable-libx264--enable-libxvid--cc= ARM-XILINX-LINUX-GNUEABI-GCC--enable-swscale--extra-cflags=-i$zynq_cv_build/include--extra-ldflags=-L$ZYNQ_CV_ 

Build/lib--disable-asm make made install echo "\n\n===================== third-party dependent library file compilation complete =======================" Sleep 5 echo "\n\n====================== Copy library file to the file where GCC is located =======================" Sleep 2 # cp/opt/opencv3/include/*/Root/codesourcery/sourcery_codebench_lite_for_xilinx_gnu_linux/arm-xilinx-linux-gnueabi/include/-R #cp/o/root/ Codesourcery/sourcery_codebench_lite_for_xilinx_gnu_linux/arm-xilinx-linux-gnueabi/lib Sleep 5 echo "\n\n========= ============= Packaging backup ======================= "Tar cvf/opt/opencv3.tar/opt/opencv3/echo" \n\n======================
 Next you are ready to install OPENCV2/3 ======================= "

Three: Start configuration OpenCV

Create a Build folder under OpenCV

   

    OPENCV installation is relatively easy and requires installation of CMake and Cmake-gui configuration tools before compiling. In fact, the configuration process is very similar to Windows, except that you need to modify some paths and options and make the compiler.

sudo apt-get install CMake Cmake-gui
You can also install Ccmake
sudo apt-get install CMake Cmake-curses-gui




    

Four: cross-compiling OPENCV

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.