Ubuntu 14.04 LTS use MIPS-LINUX-GNU-GCC to cross-compile OpenCV required libraries __linux

Source: Internet
Author: User
Thank you so much
http://blog.h5min.cn/ajianyingxiaoqinghan/article/details/70194392
http://blog.h5min.cn/zdyueguanyun/article/details/51322295
http://blog.csdn.net/tgww88/article/details/51393570


1, zlib of the cross-compilation:


./configure--prefix= $OPENCV _depend
1
1
After that, the makefile file is modified and the contents are as follows:


cc=mips-linux-gnu-gcc
Ldshared=mips-linux-gnu-gcc-shared-wl,-soname,libz.so.1,--Version-script,zlib.map
Cpp=mips-linux-gnu-gcc-e




Ar=mips-linux-gnu-ar
Arflags=rc
Ranlib=mips-linux-gnu-gcc-ranlib






2, Libjpeg of the cross-compilation:


./configure--host=mips-linux-gnu--prefix= $OPENCV _depend--enable-shared--enable-static
Make
Make install




3, libpng of the cross-compilation:


./configure--host=mips-linux-gnu--prefix= $OPENCV _depend--enable-shared--enable-static
Error
Configure:error:zlib not installed


Export Ldflags=-l$rootfs_dir/usr/local/mips/opencv-depend/lib
Export Cflags=-i$rootfs_dir/usr/local/mips/opencv-depend/include
./configure--host=mips-linux-gnu--prefix= $OPENCV _depend--enable-shared--enable-static
Make
Still error, prompt
Pnglibconf.c:33:19:fatal error:zlib.h:no such file or directory


Reference http://code-by.org/viewtopic.php?f=55&t=169
Vim Makefile +256 instead
Default_includes =-I.-i/usr/local/mips/opencv-depend/include
Make
Make install


4, Yasm of the cross-compilation:


CC=MIPS-LINUX-GNU-GCC./configure--enable-shared--host=mips-linux-gnu--disable-asm--prefix= $OPENCV _depend
Make
Make install




5, libx264 of the cross-compilation:


CC=MIPS-LINUX-GNU-GCC./configure--enable-shared--host=mips-linux-gnu--disable-asm--prefix= $OPENCV _depend
Make
Make install




6, Libxvid of the cross-compilation:


After entering the Libxvid directory, the line enters its subdirectory:


CD./build/generic


Then enter the command:


./configure--prefix= $OPENCV _depend--host=arm-linux--disable-assembly
Make
Make install




7, FFmpeg of the cross-compilation:


./configure--prefix= $OPENCV _depend--enable-shared--disable-static--ENABLE-GPL--enable-cross-compile--arch=mips --disable-stripping--target-os=linux--


enable-libx264--enable-libxvid--CC=MIPS-LINUX-GNU-GCC--enable-swscale--extra-ldflags=-l$opencv_depend/lib-- Extra-cflags=-l$opencv_depend/include


./configure--prefix= $OPENCV _depend--enable-shared--disable-static--ENABLE-GPL--enable-cross-compile--arch=mips --disable-stripping--target-os=linux--


enable-libx264--enable-libxvid--CC=MIPS-LINUX-GNU-GCC--enable-swscale--extra-ldflags=-l$opencv_depend/lib-- Extra-cflags=-i$opencv_depend/include


7, FFmpeg of cross compilation:


./configure--cross-prefix=mips-linux-gnu---enable-cross-compile--target-os=linux--cc=mips-linux-gnu-gcc--arch= MIPS--prefix= $OPENCV _depend--enable-shared


--disable-static--ENABLE-GPL--enable-nonfree--enable-ffmpeg--disable-ffplay--enable-ffserver-- Enable-pthreads--disable-armv5te--


Disable-armv6--disable-armv6t2--disable-yasm--disable-stripping--enable-libx264--extra-ldflags=-L$OPENCV_ Depend/lib--extra-cflags=-i$opencv_depend/include


--extra-libs=-ldl


Make


Make install
Note: Download the FFmpeg 2.8 version in accordance with the process installation and do not download the latest FFmpeg 3.3 version. Otherwise, you might be able to display make errors as I compile OpenCV to 21%.




Makefile Option Cflags,ldflags,libs
Cflags represents the options for the C compiler,
Cxxflags represents the options for the C + + compiler.
These two variables actually cover the two steps of compiling and compiling.


Cflags: Specifies the path to the header file (. h file), such as: Cflags=-i/usr/include-i/path/include. Similarly, installing a package creates an include directory under the installation path, and when a problem occurs during installation, try


Add the Include directory of the previously installed package to the variable.


Some of the tuning parameters that the compiler uses, such as LDFLAGS:GCC, can also be used to specify the location of the library files. Usage: ldflags=-l/usr/lib-l/path/to/your/lib. Each installation of a package is almost certain to be built in the installation directory


A Lib directory. If a package is installed, and another package is installed, it Leng said it could not find, can express the package of Lib path to join the Ldfalgs to try.


LIBS: Tell the linker which library files to link to, such as LIBS =-lpthread-liconv


Simply put, Ldflags tells the linker where to look for the library file, and Libs tells the linker which library files to link to. However, when you use the link phase these two parameters will be added, so you even if the two values are interchangeable, there is no problem.


Sometimes ldflags specifies-l although it allows the linker to find the library for linking, but the runtime linker cannot find the library, and if the path to the software Run-time library file is extended, then we need to add the two libraries to the "-wl,r":


Ldflags =-l/var/xxx/lib-l/opt/mysql/lib-wl,r/var/xxx/lib-wl,r/opt/mysql/lib


If you set the environment variable before executing./configure export ldflags= "-l/var/xxx/lib-l/opt/mysql/lib-wl,r/var/xxx/lib-wl,r/opt/mysql/lib", Note Set the environment variable equal sign on either side can not be empty


Lattice, and enclose the quotation marks (use of the shell). Then after executing configure, makefile will set this option, the link will have this parameter, the compiled executable program's library file search path is expanded.

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.