My Environment
HOST: VMWare + Ubuntu 10.04
Target: real6410 with Linux 2.6.38
Crossing compiler: Arm-Linux-GCC 4.4.3
Installation of a cross-compilation chain
1. decompress the package to obtain the arm-None-Linux-gnueabi directory.
# Tar-xjvf arm-none-linux-gnueabi-4.3.2.tar.bz2
2. For ease of use,
You can also edit the/etc/bash. bashrc file and add the compiler path to the environment variable path,
Add the following two statements to the file:
Path =/root/arm-none-linux-gnueabi-4.1.0/bin: $ path
Export path
3. After editing, run the source/etc/bash. bashrc command to execute the following file, make the settings take effect, and then enter
Inbound:
# Arm-None-Linux-gnueabi-gcc-V
If the following information is output, the surface settings are successful:
Using built-in specs.
Target: Arm-None-Linux-gnueabi
Configured with:/scratch/Julian/Lite-respin/Linux/src/gcc-4.3/configure -- Build = i686-pc-
Linux-
GNU -- Host = i686-pc-linux-gnu -- target = arm-None-Linux-gnueabi -- enable-threads -- disable-
Libmudflap -- disable-libssp -- disable-libstdcxx-PCH -- With-GNU-as -- With-GNU-LD -- enable-
Ages = C, C ++ -- enable-shared -- enable-symvers = GNU -- enable-_ cxa_atexit ---
Pkgversion = 'sourcery g ++ lite 2008q3-72 '---
Bugurl = https://support.codesourcery.com/GNUToolchain/ -- disable-NLS
-- Prefix =/opt/codesourcery
-- With-sysroot =/opt/codesourcery/ARM-None-Linux-gnueabi/libc -- With-Build-
Sysroot =/scratch/Julian/Lite-respin/Linux/install/ARM-None-Linux-gnueabi/libc ---
GMP =/scratch/Julian/Lite-respin/Linux/obj/host-libs-2008q3-72-arm-none-linux-gnueabi-
I686-pc-
Linux-GNU/usr -- With-mpfr =/scratch/Julian/Lite-respin/Linux/obj/host-libs-2008q3-72-arm-
None-
Linux-gnueabi-i686-pc-linux-gnu/usr -- disable-libgomp -- enable-poison-system-Directories
---
Build-time-tools =/scratch/Julian/Lite-respin/Linux/install/ARM-None-Linux-gnueabi/bin ---
Build-
Time-tools =/scratch/Julian/Lite-respin/Linux/install/ARM-None-Linux-gnueabi/bin
Thread model: POSIX
1opencv porting to arm process by Ken Cheung
GCC version 4.3.2 (sourcery g ++ lite 2008q3-72)
So far, the installation of the Cross-compilation chain is complete.
2. Cross-compile libjpeg
To enable opencv to process JPEG images, we must compile libjpeg in advance.
The version used here is javassrc. v6b.
Download libjpeg source code: ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz
2. decompress the package to the directory.
3 Configuration
#./Configure -- prefix =/root/libjpeg-arm -- Exec-Prefix =/root/libjpeg-arm -- enable-shared
-- Enable-static
The following describes the functions of these parameters:
-- Prefix =/root/libjpeg-arm: After you execute make install, the file irrelevant to the system will be copied to this directory,
Body:
/Root/libjpeg-arm .....................................
|
+ --- Include ........................................
|
--- Jconfig. h
|
--- Jerror. h
|
--- Jmorecfg. h
|
--- Using Lib. h
+ --- Man ..................................... .......
|
+ --- Man1 .......................................
|
--- Cjeg.1
|
--- Djpeg.1
|
--- Jpegtran.1
|
--- Rdjpgcom.1
|
--- Wrjpgcom.1
-- Exec-Prefix =/root/libjpeg-arm: After you execute make install, the System-independent files will be copied to this directory.
To copy some executable programs, dynamic and static link libraries to the corresponding directory, as shown below:
2opencv porting to arm process by Ken Cheung
/Root/libjpeg-arm .................................. ......
|
+ --- Bin ..................................... .......
|
--- Cjeg
|
--- Djpeg
|
--- Pivotran
|
--- Rdjpgcom
|
--- Wrjpgcom
+ --- Lib ..................................... ......
|
--- Libjpeg. La
|
--- Libjpeg. So
|
--- Libjpeg. so.62
|
--- Libjpeg. so.62.0.0
-- Enable-shared: Use GNU libtool to compile a dynamic link library.
4. Modify the generated makefile:
# The name of your C compiler:
Cc = GCC cc =/root/ARM-None-Linux-gnueabi/bin/ARM-None-Linux-gnueabi-gcc
(Based on the position of your own cross compiler)
# Library (. a) File Creation command
AR = ar RC: Ar =/root/ARM-None-Linux-gnueabi/bin/ARM-None-Linux-gnueabi-ar RC
(Same as above)
# Second Step in. A creation (use "Touch" if not needed)
AR2 = ranlib: AR2 =/root/ARM-None-Linux-gnueabi/bin/ARM-None-Linux-gnueabi-
Ranlib (same as above)
5. create man/Man1, include, Lib, and bin in the/root/libjpeg-arm directory.
6 # Make
# Make install
7. Copy the header files/root/libjpeg-arm/include/(jconfig. H, jerror. H, jmorecfg. H, and mongolib. h)
Bay to:/root/ARM-None-Linux-gnueabi/include.
In/root/libjpeg-arm/lib (libjpeg. LA, libjpeg. So, libjpeg. so.62, libjpeg. so.62.0.0 ),
Copy the file to/root/ARM-None-Linux-gnueabi/lib.
Note: run the following command to check whether the generated libjpeg. So version is arm:
3opencv porting to arm process by Ken Cheung
# File libjpeg. So
The following is the correct output. Otherwise, check the cross-compiler path and makefile and re-compile.
Note: After performing the preceding operations, run the following command to check whether the library file is correctly installed:
# Arm-Linux-gcc-print-file-name = libjpeg. So
If the output is "libjpeg. So", it indicates that the installation is not correct. Repeat Step 7.
If the output is "DIR/libjpeg. So", the installation is correct.
At this point, libjpeg cross-compilation is complete.
Xvid, FFMPEG
To enable opencv to process videos, We need to compile FFMPEG in advance, while FFMPEG depends on x264 and
XviD.
1 download yasm:
Download yasm0.7.2 from http://www.tortall.net/projects/yasm/wiki/Download (x264 required
To compile the compiler)
#./Configure -- enable-shared -- prefix =/root/ARM-None-Linux-gnueabi/ARM-None-Linux-
Gnueabi/-- Host = arm-Linux
# Make
# Make install
2. Cross-compile x264
Download ftp://ftp.videolan.org/pub/videolan/x264/snapshots/ to x264-snapshot-20060805-
2245.tar.bz2, decompress it to the directory
(1). Configuration
#./Configure -- prefix =/root/ARM-None-Linux-gnueabi/-- enable-
Shared
(2). modify configuration parameters
Modify config. Mak:
Prefix =/root/ARM-None-Linux-gnueabi/
Exec_prefix =$ {prefix}
Bindir =$ {exec_prefix}/bin
Libdir =$ {exec_prefix}/lib
Includedir =$ {prefix}/include
# Change to arm here
Arch = arm
Sys = Linux
# Here we will change it to arm-Linux-GCC.
Cc = arm-Linux-gcc
# Remove-dhave_mmxext-dhave_sse2-darch_x86
Cflags =-wall-I.-O4-ffast-math-d1_x264 _-dhave_malloc_h-dsys_linux
-Dhave_pthread-S-fomit-frame-pointer
Ldflags =-lm-lpthread-S
As = NASM
The entire process of porting 4opencv to arm by Ken Cheung
Asflags =-O2-F elf
VFW = No
GTK = No
EXE =
Vis = No
Have_getopt_long = 1
Devnull =/dev/null
Configure_args = '-- enable-shared ''-- prefix =/root/ARM-None-Linux-gnueabi/ARM-
None-Linux-gnueabi /'
Soname = libx264.so. 49
Default: $ (soname)
Modify makefile to change the value from 66 ~ Replace the AR and ranlib values in 68 rows with those in arm:
Libx264.a:. Depend $ (objs) $ (objasm)
Arm-Linux-ar RC libx264.a $ (objs) $ (objasm)
Arm-Linux-ranlib libx264.a
(3). Compile and install
# Make
# Make install
Here, you can go to the Cross-compiled chain directory/root/ARM-None-Linux-gnueabi/
Generate libx264.so in lib
3. Cross-compile Xvid
Download Xvid to http://downloads.xvid.org/downloads/xvidcore-1.1.3.tar.gz
Download the Xvid and decompress it to build/generic.
Configuration
#./Configure -- prefix =/root/ARM-None-Linux-gnueabi/-- disable-
Assembly
[Explanation] -- disable-assembly: Because Xvid is not optimized for arm assembly, the aggregation must be disabled during compilation.
Editing
Modify the platform. inc file referenced by makefile and change cc = GCC to CC = arm-Linux-GCC.
# Make
# Make install
Go to the example folder
Test, input
Arm-Linux-gcc-O xvid_encraw xvid_encraw.c-LC-lm-I ../src/-l ../build/generic/= build
Full Process of porting 5opencv to arm by Ken Cheung
-Lxvidcore
You can generate xvid_encraw.
Here, you can go to the Cross-compiled chain directory/root/ARM-None-Linux-gnueabi/
Include, lib generate the corresponding header file and Library File
4. Cross-compile FFMPEG
To http://download.chinaunix.net/download.php? Id = 5532 & resourceid = 2990 at this URL
Download ffmpeg-0.4.9-p200w.tar.bz2 and decompress the package.
Modify the configure file as follows:
Since CC, AR, ranlib, and strip are all execution files in the Cross-compiling environment, you can configure them as follows:
Prefix = "/root/ARM-None-Linux-gnueabi /"
Cross_prefix = "root/ARM-None-Linux-gnueabi/bin/ARM-Linux -"
CPU = "arm"
Configuration
#./Configure -- CPU = arm -- cc = arm-Linux-GCC -- enable-shared -- disable-ffserver -- enable-
Xvid -- enable-x264 -- enable-GPL -- enable-pthreads -- disable-strip
# Make
# Make install
Go to the FFMPEG source file package and run the following command:
Export cc = arm-Linux-GCC; export AR = arm-Linux-Ar; export LD = arm-Linux-LD; export ranlib = arm-Linux-ranlib
./Configure -- CPU = armv4l -- Cross-Prefix =/usr/local/ARM/3.3.2/bin/ARM-Linux--- cc = GCC -- disable-opts -- enable-shared
Make
...
When making buildroot rootfs, a problem occurred while compiling the MPlayer-1.0rc1:
Armv4l/dsputil_arm_s.s: 79: Error: Selected processor does not support 'pld [R1]'
Like a person on the Internet:
Cross-compiling x264 FFMPEG on the S3C2410 embedded platform for help!
"It seems that commands that are not supported are very strange. If arch = arm is specified, how can an unsupported command appear. Is my version incorrect"
It is strange that you have configured the command as an arm, but it does not support the command,
Then I found the following explanation on the Internet:
Re: 3.5.4.1 status update and BSP request: MSG #00003
"
The PLD instruction can just be ignored on arm4-worst case it can be
Commented/patched out or made conditional on arm5 +. Its there
"Preload" memory so its safe to just ignore it on arches which don't
Support it. I believe glibc uses macros for the function which only
Result in the instruction being present in the arm5 + case. If you still
Have problems, let me know and I'll try and look into it.
"
This indicates that the PLD command is only supported by arm5 or above. Here, my configuration is arm922t, which belongs to arm4,
This command is not supported and can be ignored directly. Therefore, use the following method,
You can avoid this problem by manually adding a macro definition:
Porting FFMPEG to wince in cygwin
"3. armv4l/dsputil_arm_s.s: 79: Error: Selected processor does not support 'pld [R1]'
This is an external definition,
# Ifndef have_pld
. Macro PLD Reg
. Endm
# Endif
"
That is, modify the dsputil_arm_s.s and add it in front of it:
# Ifndef have_pld
. Macro PLD Reg
. Endm
# Endif
You can. In fact, it is better to determine that the structure of the arm system is less than 5. This PLD command is not supported, and then this definition is added.
[Solution 2]
Someone on the Internet has changed the arm GCC compiler version to solve this problem:
Http://www.itdp.de/mplayer-users/2006-03/msg00308.html
"It seems this problem is realted to the arm GCC 4.0. I used another arm GCC 4.1"
And did not receive this error message ."
Here, you can go to the Cross-compiled chain directory/root/ARM-None-Linux-gnueabi/
Include, lib generate the corresponding header file and Library File
So far, the libraries on which opencv depends are all cross-compiled, and under include, bin, share, and Lib in the Cross-compilation chain
Corresponding File
Cross-compiling opencv
Download OpenCV-1.0.0 source code http://www.opencv.org.cn/download/opencv-1.0.0.tar.gz
Decompress the package and enter the directory configuration.
#./Configure -- Host = arm-None-Linux-gnueabi -- without-GTK -- without-carbon ---
QuickTime -- without-1394libs -- With-FFMPEG -- without-Python -- without-swig -- enable-static
-- Enable-shared -- disable-apps cxx = arm-None-Linux-gnueabi-G ++ cppflags =-
I/root/ARM-None-Linux-gnueabi/include ldflags =-L/root/ARM-
The entire process of migrating 6opencv to arm by Ken Cheung
None-Linux-gnueabi/ARM-None-Linux-gnueabi/lib -- with-v4l -- prefix =/root/opencv-arm
-- Libdir =/root/opencv-arm/lib -- includedir =/root/opencv-arm/include
Note:
-- Host = arm-None-Linux-gnueabi: indicates the cross-compiling ARM platform.
-- Without-GTK: Ignore GTK + 2.0 windows
-- Without-carbon: Do not use the X library on Mac OS
-- Without-QuickTime
Without-1394libs
-- Without-FFMPEG
-- Without-Python
-- Without-swig
-- Enable-static: generate static library
-- Enable-shared: generate a dynamic library
Cxx = arm-None-Linux-gnueabi-G ++: Specify the compilation tool
Cppflags =-I/root/ARM-None-Linux-gnueabi/include:
Opencv will use some Dev packages, such as PNG. h and unzip Lib. H. Most of the header files are under/usr/include.
-- Prefix =/root/opencv-arm: Specifies the installation directory
-Libdir =/root/opencv-arm/lib: Specifies the library file installation location
-- Includedir =/root/opencv-arm/include: Specifies the installation location of the included files.
If the configuration is correct, the following information will be displayed:
General configuration = ============
Compiler: Arm-None-Linux-gnueabi-G ++
Cxxflags:-wall-fno-rtti-pipe-O3-fomit-frame-pointer
Install path:/root/opencv-arm
Highgui configuration = ============
Windowing system --------------
Use carbon/Mac OS X: No
Use GTK + 2.x: No
Use gthread: No
Image I/O ---------------------
Use libjpeg: Yes
The entire process of porting 7opencv to arm by Ken Cheung 2010-7-23
Use zlib: Yes
Use libpng: Yes
Use LibTIFF: No
Use libjasper: No
Use libilmimf: No
Video I/O ---------------------
Use quicktime/Mac OS X: No
Use xine: No
Use FFMPEG: Yes
Use dc1394 & raw1394: No
Use v4l: Yes
Use v4l2: Yes
Wrappers for other development ages ========================================== =====
Swig
Python No
Additional build settings ====================================== ========
Build demo apps No
Now run make...
========================================================== ======================================
===
# Make
.../../Cxcore/include/cxmisc. h: 133: 6: Error: # Elif with no expression
Change # Elif to # else
# Make install
Required libraries for running opencv on arm:
1. Run the/root/opencv-arm/lib File
Libcvaux. so.1.0.0
Libcv. so.1.0.0
Libcxcore. so.1.0.0
Libhighgui. so.1.0.0
Libml. so.1.0.0
Copy and rename all
*. So.1
2. Add the previous library file to/root/ARM-None-Linux-gnueabi/lib
Libjpeg, Xvid, x264, and FFMPEG databases can be copied to/usr/lib or/lib of the Board.
And # export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/Your/lib/Dir
3 opencv database summary table:
The entire process of migrating 8opencv to arm by Ken Cheung
Compile source file Method
Arm-None-Linux-gnueabi-G ++ demo. C-o demo-I/root/opencv-arm/include/opencv
-L/root/opencv-arm/lib-LCV-lcxcore-lpthread-LRT-lcvaux-lm-lpng-ljpeg-LZ-lml-lhighgui
-LDL
Finally, copy the generated binary file to the Board to run it.
9
Many errors occurred during the period... Unfortunately, it was not recorded... But I am not afraid of these errors.