The transplant of Opencv-2.49 on the mini2440

Source: Internet
Author: User

1. Pre-preparation work

A. Installing the cross-compilation chain
I'm using ARM-LINUX-GCC 4.3.2, unzip to the directory/usr/local/arm/4.3.2, and add/usr/local/arm/4.3.2/bin in the environment variable path

B. Installing CMake
OPENCV after 2.0, you must use CMake to create the makefile. The CMake version I used was 2.8.2, extracted to the directory/usr/local/cmake-2.8.2-linux-i386, and added/usr/local/cmake-2.8.2-linux-i386/bin in the environment variable path

2. Compiling OpenCV

1, decompression OpenCV 2.4.9

2, create the build directory, as CMake compiled arm version of the working directory

3, in the X environment, run Cmake-gui (if not installed, follow the prompts to install a)
Select Source Code Directory
Select the build directory:


Click Configure, keep generator for Unix makefiles, select specify options for Cross-compiling, click Next
Operating System Fill Arm-inux



Click Next to jump out of the interface to do the following settings

Operating System Select Target Systems Arm-linux

Compilers select the cross compiler for GCC and g++

Target Root Select the path of the cross compiler



Library target root fill in the/usr/local/arm/and click Finish

Click the Finish button to start generating the configuration file, but this time the error will be

System is unknown to CMake, create:

Platform/arm-linux to use the This system, please send your config file to [email protected] so it can added to CMake

this is because the operating system fills in the Arm-linux does not calculate cmake to be able to identify the target systems, here can ignore this error.

But there are other mistakes at this time.

CMake Error at cmake/findcuda.cmake:763 (IF):

If given arguments:


"Cuda_version" "Version_greater" "5.0" "and" "Cmake_crosscompiling" "and" "MATCHES" "Arm"


Unknown arguments specified

Call Stack (most recent call first):

Cmake/opencvdetectcuda.cmake:26 (Find_package)

Cmake/opencvfindlibsperf.cmake:24 (include)

cmakelists.txt:468 (include)


It should be my computer does not have the Cuda library, because the development of the later will not use Cuda, so I will with_cuda the hook off, and then click the Configure button to see if there are no hints missing third-party libraries, other articles on the internet said With_ TIFF is to be removed, but there is no error here, regardless of it. You can also change the cmake_install_prefix to the path you want, the path OpenCV the last library file and the installation path of the header file. In the absence of other problems after clicking on the Generate survival makefile file, if the previous third party problem is not resolved here is an error can not survive makefile. The generated makefile files and CMake configuration files are under the folder set in Wher to build the Binarier



Modify the default configuration, the default installation directory is/usr/local, because I have installed x86 version of OpenCV, so it is not suitable for cross-compiled libraries, so I changed the cmake_install_prefix variable to/usr/local/ arm/


4. Click Generate to generate makefile

(1) If you make now, you are sure to get it wrong! (Do not modify, may be white for at least 15 minutes, the precedent)

.. /.. /lib/libopencv_core.so:undefined reference to ' Pthread_spin_init '

.. /.. /lib/libopencv_core.so:undefined reference to ' Pthread_spin_unlock '
.. /.. /lib/libopencv_core.so:undefined reference to ' Pthread_spin_lock '
.. /.. /lib/libopencv_core.so:undefined reference to ' Pthread_spin_destroy '
.. /.. /lib/libopencv_core.so:undefined reference to ' pthread_once '
.. /.. /lib/libopencv_core.so:undefined reference to ' Clock_gettime '
.. /.. /lib/libopencv_core.so:undefined reference to ' Pthread_spin_trylock '

The reason is that you cannot find the Pthread link library, open the folder under CmakeCache.txt to modify

//flags used by the linker. (around 194 rows)
Cmake_exe_linker_flags:string=-lpthread-lrt


(2) OpenCV compile OpenEXR to use libimath.so,

BUILD_OPENCVXR and WITH_OPENCVXR should be removed from the configuration interface . , otherwise this problem will occur.

/usr/lib/libimath.so:could not read symbols:file in wrong format

Collect2:ld returned 1 exit status

MAKE[2]: * * [lib/libopencv_highgui.so] Error 1

MAKE[1]: * * [Modules/highgui/cmakefiles/opencv_highgui.dir/all] Error 2 Make: * * * [ALL] Error 2

Also remove Build_opencv_ocl and WITH_OPENCL, or you will get the following error

.. /.. /lib/libopencv_ocl.so:undefined reference to ' Dlopen '

And get rid of the TIFF Library compilation.


5. Make

6.sudo make install


3, Test OpenCV Library is installed correctly
#include "cv.h" #include "highgui.h" Const Char*picture = "lena.jpg"; int main (int argc,char** argv) {iplimage *pimage= Cvloadimage (picture,1); Cvnamedwindow ("Test", cv_window_autosize); Cvshowimage ("Test", Pimage); Cvwaitkey (0); Cvreleaseimage (&pimage); Cvdestroywindow ("Test");}

ALL:TESTCFLAGS=-WALLOPENCV_INCLUDE=-I/USR/LOCAL/ARM/INCLUDE/OPENCVCC = Arm-linux-g++opencv_link =-L/usr/local/arm /lib-lcv-lcxcore-lhighgui-lpthread-lrt%:%.cpp#$ (CC) ' Pkg-config OpenCV--libs ' $ (opencv_include) $<-o [Email prot Ected] $ (opencv_link) $ (CC) $ (opencv_include) $<-o [email protected] $ (opencv_link). Phony:cleanclean:rm-f Test

4. Porting to the mini2440 Development Board

First copy all the. So files under the host/usr/local/arm/lib//to the/lib/directory of the embedded root file system, and then copy our compiled test to the embedded system/opt/myworks/directory (and ensure that the file test property is executable), if test runs without reporting a missing library file, our compiled version of the Arm-linux OpenCV Library is ready to work.

The transplant of Opencv-2.49 on the mini2440

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.