OpenCV Arm porting (cross-compiling OpenCV)

Source: Internet
Author: User

 part of the content is from the following 2 articles:http://www.cnblogs.com/emouse/archive/2013/04/01/2993842.html

http://blog.csdn.net/satanhbl/article/details/25734887

ARM-OE-LINUX-GNUEABI-GCC compiling opencv3.1.0

Installation of CMake

OpenCV 2.2 will require CMake to generate the makefile file, so you will need to install CMake first.

Installing CMake under Ubuntu is relatively simple,

Apt-get Install CMake

If you feel that your own version does not meet the requirements, you can download the installation package.

Download the latest version of the installation package:

Http://www.cmake.org/cmake/resources/software.html

Here the download has been compiled so that only need to extract to the desired directory can be used:

Tar zxvf cmake-2.8.10.2-linux-i386.tar.gz–c/usr/local/

Set Environment variables:

sudo gedit/home/emouse/.bashrc

After opening the file, add:

Export path= $PATH:/usr/local/cmake-2.8.10.2-linux-i386/bin

Review the version to test if the installation was successful:

[Email protected]:/home# cmake--version

OpenCV Cross-compiling

Unzip the OpenCV compressed file and get the folder.

#cmake-gui Open the CMake GUI interface and start the configuration process as shown in:

First, the computer must first install Arm-linux cross-compiling environment, here does not introduce this, directly say the key.

Method one (Compile pass):

1, in the terminal window input sudo apt-get install Cmake-qt-gui download CMake graphical interface

2, after installation in the Terminal window input Cmake-gui open CMake GUI interface


3. In "Where is the source code", fill in the location of the OpenCV source code in the computer, "where to build the binaries" fill in the location to generate the make compile file, and then click the Configure button, select the last item


4. 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++

Note here to choose what to compile, choose the path to compile the command according to the different compilation.

I am using the Arm-oe-linux-gnueabi to compile, find the compiler installation path:/usr/local/oecore-i586/sysroots/i586-oesdk-linux/usr/bin/ cortexa9hf-vfp-neon-oe-linux-gnueabi/

gcc:/usr/local/oecore-i586/sysroots/i586-oesdk-linux/usr/bin/cortexa9hf-vfp-neon-oe-linux-gnueabi/ arm-oe-linux-gnueabi-gcc

g++:/usr/local/oecore-i586/sysroots/i586-oesdk-linux/usr/bin/cortexa9hf-vfp-neon-oe-linux-gnueabi/ arm-oe-linux-gnueabi-g++

Target Root Select the path of the cross compiler


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


6. At this time the main interface as shown, then CMake will read some configuration information of the program, you can then modify each of the compilation options in the Red box, remove With_tiff, Modify the Cmake_find_root_path installation path::/usr/ local/oecore-i586/sysroots/i586-oesdk-linux/usr/bin/cortexa9hf-vfp-neon-oe-linux-gnueabi/.

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 to remove , but there's no error here, just ignore it.


7. 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



8.

To execute the make command under the folder set in the wher to build binarier in the terminal window, make failure prompt is as follows


.. /.. /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 '

Flags used by the linker.
Cmake_exe_linker_flags:string=-lpthread-lrt

LRT this does not know what is, just online other articles said to add I also added, and then continue to compile, after the completion of the compilation command make install the installation library files and header files to cmake_install_prefix the folder specified. Although there are many articles on the Internet is written using this method, are this method is problematic, the previous mentioned configure when prompted by the system is unknown to CMake, this error is directly ignored by me, are actually this is very problematic, Because we didn't tell the compiler what system we were using during the CMake compilation, there are some features that don't know whether to choose Compiled and window-compatible code, or Linux-compatible code, For example, I used this compiled OpenCV library to write the program put to 210 of the board running, the software comes with the function of Cvcreatcamercapture no way to identify the board USB camera, Google looked for a long time to find that it was compiled without support V4L2, Later found to be the problem of the target system selection, the following other method will solve the problem.

Method Two (compilation does not pass):

The System was unknown to CMake that was prompted by the previous configure is ignored by me, regardless of the following introduction, the compilation process does not ignore this error.

The reason for this error is that CMake does not recognize the arm-linux system, so we change it to Linux, pay attention to the first letter capitalization, can't write wrong Linux, or else the error will occur


It is also important to note that the Include mode should be selected as search only in Target root so that the search header files at the end of the OpenCV compile will only be searched under Target Root, not the usr/of your computer. include/Search, if this is still the previous search in Target Root, then native system will go to/usr/include/under the head file, there will be some problems,

10. The following problem has occurred in my computer


/usr/include/bits/mathinline.h:675:3: error: unknown register name ‘st‘ in ‘asm‘
/usr/include/bits/mathinline.h:675:3: error: unknown register name ‘st‘ in ‘asm‘
/usr/include/bits/mathinline.h:675:3: error: unknown register name ‘st‘ in ‘asm‘

mathinline.h in/usr/include/bits/and/opt/friendlyarm/toolschain/4.5.1/arm-none-linux-gnueabi/sys-root/usr/include/bits/directories, At this time, the first choice of/usr/includeMathinline.h, so the compilation is wrong, before the operating system for Arm-linux Why did not this error? The author thinks that it is possible to search for the Arm-linux path configured in the computer by default when Arm-linux/opt/friendlyarm/toolschain/4.5.1/Under the Include folder, and if set to Linux it is preferred to search for /usr/include. Therefore, to select the Include mode as search only in Target Root, this will only be searched for the header file under the/opt/friendlyarm/toolschain/4.5.1/folder when compiling.

11. Then the back and the same as before the Cuda third-party library, change Cmake_install_prefix, change the PostScript and then click again configure and then click Generate, go to the folder to modify CmakeCache.txt, make, this time again error:

Undefined reference to ' Dlopen '

No DL libraries found, continue to modify CmakeCache.txt

Cmake_exe_linker_flags:string=-lpthread-lrt-ldl

Compile after make install, this time in fact, we will find this method compiled links cubby The first method compiled out of the link library to more, in the current embedded development phase of the use of this link library has not found anything. In fact, I just transplanted a software, haha!

Reference Documentation:

Http://www.cnblogs.com/emouse/archive/2013/04/01/2993842.html

http://blog.csdn.net/noodies/article/details/5798434

Http://www.bubuko.com/infodetail-534692.html

http://blog.csdn.net/zdyueguanyun/article/details/51262136

http://blog.csdn.net/zdyueguanyun/article/details/51273547





OpenCV Arm porting (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.