Host system: ubuntu9.04 cross compiler arm-linux-gcc-4.3.2
Target Board: Arm-cotex (am3517), Linux system, kernel: 2.6.3.2
Step 1 install the cross-compiler tool arm-linux-gcc-4.3.2
Xgy @ Ubuntu :~ /Toolchain $ mkdir arm
Xgy @ Ubuntu :~ /Toolchain $ CD arm
Xgy @ Ubuntu :~ /Toolchain/ARM $ tar xvf arm-linux-gcc-4.3.2
After decompression, there will be an additional USR directory under the directory, because I don't like this directory too deep, then execute the following command:
Xgy @ Ubuntu :~ /Toolchain/ARM $ CP-RV usr/local /*.
Xgy @ Ubuntu :~ /Toolchain/ARM $ Rm-RF USR
Next, set the environment variable path and run the following command:
Xgy @ Ubuntu :~ /Toolchain/ARM $ cd
Xgy @ Ubuntu :~ $ VI. bashrc
Add exportpath = $ path:/home/xgy/toolchain/ARM/4.3.2/bin at the end of the. bashrc file to save and exit (: WQ)
Xgy @ Ubuntu :~ $ Source. bashrc // make the set value take effect
By now, the cross-compilation tool has been installed successfully. You can check the left column of arm-Linux-G ++, the arm-Linux-GCC version is 4.3.3 (you can use the command arm-Linux-gcc-V to view it), while other versions are indeed. 4.3.2 is a strange phenomenon!
Because I have tried to use g ++ of version 4.3.3 To cross-compile opencv2.0, there is always an error as follows:
Here, I have to create a soft link so that it points to the Right Arm-None-Linux-gnueabi-G ++, arm-None-Linux-gnueabi-GCC. Back up the original two files before they are created. Run the following command:
Check the arm-Linux-GCC and arm-Linux-G ++ versions again.
The last line output by the command arm-Linux-gcc-V should be: GCC version 4.3.2 (sourcery g ++ lite 2008q3-72). This is very important: the currently used arm-Linux-GCC actually uses ~. /Toolchain/ARM/4.3.2/bin/directory of arm-None-Linux-gnueabi-GCC, its include is ARM/4.3.2/ARM-None-Linux-gnueabi/include, and its corresponding Lib is ARM/4.3.2/ARM-None-Linux-gnueabi/lib, that is, if you use arm-Linux-GCC to compile the program, find ARM/4.3.2/ARM-None-Linux-gnueabi/include by default for the first file, find the database by default.
ARM/4.3.2/ARM-None-Linux-gnueabi/lib, instead of/usr/include/usr/lib, so if you want to add anything. h. a. so files, remember to add these files to these two directories. Otherwise, the cross compiler will tell you that you cannot find the desired library or header file. The principle here is also applicable to other cross compilers (mainly refers to the directory structure), but the directory names may be different.
OK. Now, the compiler is successfully installed!
The above problem was not found in the arm-Linux-GCC of version 4.3.2 today. Maybe it was an error during the previous copy. It is best to use the-A option when using the CP command.
Because opencv2.0 is lazy on zlib, PNG, and JPEG graphics libraries, while our arm-Linux-GCC does not include these libraries, it only includes some basic libraries, therefore, we must first compile these files and install them to arm/4.3.2/ARM-None-Linux-gnueabi/include, ARM/4.3.2/ARM-None-Linux-gnueabi/lib directory. The Library does not have to be up-to-date. The Library version is too new, and opencv may not recognize it.
First install the zlib library, which is the basis for compiling the next two libraries.
Xgy @ Ubuntu :~ /Tmp $ tar zxvf zlib-1.2.3.tar.gz
There will be one more zlib-1.2.3 directory under the current directory.
Because the configure script of the zlib library does not support cross-compilation options, you have to manually temporarily modify GCC to point to our cross compiler Arm-Linux-GCC. Run the following command:
Xgy @ Ubuntu :~ /Tmp $ CD/usr/bin
Xgy @ Ubuntu:/usr/bin $ Sudo-I // You must switch to the root user to perform the following operations.
[Sudo] password for xgy: // enter the xgy user password here
Root @ Ubuntu :~ # Cd/usr/bin
Root @ Ubuntu:/usr/bin # mv GCC gcc_back
Root @ Ubuntu:/usr/bin # mv LD ld_back
Root @ Ubuntu:/usr/bin # ln-SV/home/xgy/toolchain/ARM/4.3.2/bin/ARM-Linux-GCC./GCC
Root @ Ubuntu:/usr/bin # ln-SV/home/xgy/toolchain/ARM/4.3.2/bin/ARM-Linux-lD./LD
Check whether it has been changed.
Root @ Ubuntu:/usr/bin # gcc-V
GCC version4.3.2 (sourcery g ++ lite 2008q3-72) // the last line of the output
Root @ Ubuntu:/usr/bin # LD-V
Gnu ld (sourceryg ++ lite 2008q3-72) 2.18.50.20080215
Switch to the original directory ~ /Tmp/zlib-1.2.3 execute the following command
Root @ Ubuntu:/usr/bin # Su-xgy // note that suxgy is different from suxgy.-indicates the xgy environment.
Xgy @ Ubuntu :~ $ Cdtmp/zlib-1.2.3/
Xgy @ Ubuntu :~ /Tmp/zlib-1.2.3 $./configure -- prefix =/home/xgy/toolchain/ARM/4.3.2/ARM-None-Linux-gnueabi/-- shared
Xgy @ Ubuntu :~ /Tmp/zlib-1.2.3 $ make (if you have previously executed make in this directory, You need to first execute makeclean and then execute make)
Xgy @ Ubuntu :~ // Tmp/zlib-1.2.3 $ make install
Then you can go ~ /Toolchain/ARM/4.3.2/ARM-None-Linux-gnueabi/{include, lib} directory whether some files are added (you can open another terminal to check the files for convenience ), for example:
Remember to change the modified GCC back here, or an error will occur later !!!
Next, install the PNG Library, which is used to display PNG images.
Xgy @ Ubuntu :~ Libpng-1.2.18.tar.bz2/tmp $ tar jxvf
Xgy @ Ubuntu :~ /Tmp $ CD libpng-1.2.18/
Libpng does not provide a valid configure script (you can view the install file), so you have to change the MAKEFILE file by yourself.
Xgy @ Ubuntu :~ /Tmp/libpng-1.2.18 $ CP scripts/makefile. Linux makefile
Xgy @ Ubuntu :~ /Tmp/libpng-1.2.18 $ VI makefile
Cc = arm-Linux-GCC // modify here
Mkdir_p = mkdir-P
# Where "make install" putslibpng12.a, libpng12.so *,
# Libpng12/PNG. h and libpng12/pngconf. h
# Prefix must be a full pathname.
Prefix =/home/xgy/toolchain/ARM/4.3.2/ARM-None-Linux-gnueabi
Exec_prefix = $ (prefix)
# Where the zlib library and include filesare located.
# Zliblib =/usr/local/lib
# Zlibinc =/usr/local/include
Zliblib =/home/xgy/toolchain/ARM/4.3.2/ARM-None-Linux-gnueabi/lib // modify here
Zlibinc =/home/xgy/toolchain/ARM/4.3.2/ARM-None-Linux-gnueabi/include // modify here
Run the following command after saving and exiting:
Xgy @ Ubuntu :~ /Tmp/libpng-1.2.18 $ make
Xgy @ Ubuntu :~ // Tmp/libpng-1.2.18 $ makeinstall
Then you can go ~ /Toolchain/ARM/4.3.2/ARM-None-Linux-gnueabi/{include, lib} directory whether some files are added (you can open another terminal to check the files for convenience ), for example:
If there are any errors, check the previous steps. In particular, check whether there are any errors in zlib installation.
Next, install the JPEG library.
Xgy @ Ubuntu :~ /Tmp/libpng-1.2.18 $ CD ..
Xgy @ Ubuntu :~ /Tmp $ tar zxvf restart src.v6b.tar.gz
Xgy @ Ubuntu :~ /Tmp/jpeg-6b $
Xgy @ Ubuntu :~ /Tmp/jpeg-6b $./configure -- prefix =/home/xgy/toolchain/ARM/4.3.2/ARM-None-Linux-gnueabi/-- Host = arm-Linux -- enable-shared
Run this command and modify the MAKEFILE file to change the CC value to arm-Linux-GCC. You must change it !!
Xgy @ Ubuntu :~ /Tmp/jpeg-6b $ make
Create a directory in arm-Linux before installation. Otherwise, an error occurs during installation.
Xgy @ Ubuntu :~ /Tmp/jpeg-6b $ mkdir-PV/home/xgy/toolchain/ARM/4.3.2/ARM-None-Linux-gnueabi/man/Man1
Mkdir: Created directory '/home/xgy/toolchain/ARM/4.3.2/ARM-None-Linux-gnueabi/man/Man1
Xgy @ Ubuntu :~ // Tmp/jpeg-6b $ make install
Then you can go ~ /Toolchain/ARM/4.3.2/ARM-None-Linux-gnueabi/{include, lib} directory whether some files are added (you can open another terminal to check the files for convenience ), for example:
At this point, the three libraries have been installed!
Here we provide the direct load addresses of the above databases, as shown below:
OpenCV-2.0.0.tar.bz2
Http://download.csdn.net/detail/DLUTXIE/3595072
Zlib-1.2.3.tar.gz
Http://download.csdn.net/detail/DLUTXIE/3595062
Libpng-1.2.18.tar.bz2
Http://download.csdn.net/detail/DLUTXIE/3595056
Jpegsrc.v6b.tar.gz
Http://download.csdn.net/detail/DLUTXIE/3595052