Opencv2.1 cannot find libcv. So not found (try using-rpath or-rpath-link) and solve a large number of undefined references when porting arm.

Source: Internet
Author: User
Tags gtk

First, we will introduce the following environment: PC (Virtual Machine) + ubuntu11.10 + qt4.8 + arm6410 (Feiling), and declare the solution of onot found (try using-rpath or-rpath-link) the method is changed to opencv2.0, so I will try again later!

We can transplant opencv since we have transplanted qt4.8, because it is difficult to do this because we do not need to transplant visual processing algorithms! Started the opencv transplantation of egg pain, see my emergency post: http://topic.csdn.net/u/20120427/08/ae5d7b21-e58c-4b9a-8a79-a229e38195cc.html? Seed = 1445143701 & R = 78398534 # r_78398534. In order to avoid detours, I would like to explain my experiences:

(1) No matter whether it is transplanted or not, before opencv is not integrated with QT, you should first write a small example to test it. Create the test. c file with the following code:

# Include <cv. h>
# Include # Include <stdio. h>
Int main ()
{
Iplimage * IMG = cvloadimage ("/Ayan/r3.jpeg", 1 );
Cvnamedwindow ("image", 1); // create a window
Cvshowimage ("image", IMG); // display the image
Cvwaitkey (0); // wait for the key
Cvdestroywindow ("image"); // destroy the window
Cvreleaseimage (& IMG );

Printf ("OK! \ N ");

Return 0;
}

If a large number of undefined reference errors occur, check whether the compiler format is correct: GCC test. c-o Test-I/usr/include/opencv-L/usr/lib-lml-lcvaux-lhighgui-LCV-lcxcore. Test it on a PC first, note that the include directory and lib directory are the opencv installed on my Linux 386 system, not the transplanted arm version. If you write: gcc-I/usr/include/opencv-L/usr/lib-lml
-Lcvaux-lhighgui-LCV-lcxcore-O test. c. A large number of undefined reference errors may occur. The error message is as follows: extract the first few lines:

/Tmp/ccngdhso. O: In function 'cvround ':

Test. c :(. Text + 0x19): Undefined reference to 'lrint'
/Tmp/ccngdhso. O: In function 'cvdecrefdata ':
Test. c :(. Text + 0xa5a): Undefined reference to 'cvfree _'
Test. c :(. Text + 0 xacb): Undefined reference to 'cvfree _'
/Tmp/ccngdhso. O: In function 'cvgetrow ':
Test. c :(. Text + 0xbc1): Undefined reference to 'cvgetrows'
/Tmp/ccngdhso. O: In function 'cvgetcol ':
Test. c :(. Text + 0 xbec): Undefined reference to 'cvgetcols'
/Tmp/ccngdhso. O: In function 'cvreleasematnd ':
Test. c :(. Text + 0 xbff): Undefined reference to 'cvreleasemat'
/Tmp/ccngdhso. O: In function 'cvsubs ':
Test. c :(. Text + 0xd1f): Undefined reference to 'cvadds'
/Tmp/ccngdhso. O: In function 'cvcloneseq ':
Test. c :(. Text + 0xd6d): Undefined reference to 'cvseqslice'
/Tmp/ccngdhso. O: In function 'cvsetnew ':
Test. c :(. Text + 0 XDCC): Undefined reference to 'cvsetadd'
/Tmp/ccngdhso. O: In function 'cvgetsetelem ':
Test. c :(. Text + 0xe5f): Undefined reference to 'cvgetseqelem'
/Tmp/ccngdhso. O: In function 'cvellipsebox ':
Test. c :(. Text + 0xf5f): Undefined reference to 'cvellipse'
/Tmp/ccngdhso. O: In function 'cvfont ':
Test. c :(. Text + 0xfa9): Undefined reference to 'cvinitfont'
/Tmp/ccngdhso. O: In function 'cvreadintbyname ':
Test. c :(. Text + 0x1057): Undefined reference to 'cvgetfilenodebyname'
/Tmp/ccngdhso. O: In function 'cvreadrealbyname ':
Test. c :(. Text + 0x10e8): Undefined reference to 'cvgetfilenodebyname'
/Tmp/ccngdhso. O: In function 'cvreadstringbyname ':
Test. c :(. Text + 0x1142): Undefined reference to 'cvgetfilenodebyname'
/Tmp/ccngdhso. O: In function 'cvreadbyname ':
Test. c :(. Text + 0x1172): Undefined reference to 'cvgetfilenodebyname'
Test. c :(. Text + 0x1188): Undefined reference to 'cvread'
/Tmp/ccngdhso. O: In function 'cvcreatesubdiv1_ay2d ':
Test. c :(. Text + 0x1287): Undefined reference to 'cvcreatesubdiv2d'
If you have an undefined reference, check this error first!

(2) If you have not transplanted opencv, see here. Referring to several articles on the internet, I first transplanted opencv2.1 and did a good job in everything. I tested it with the correct code confirmed under the GCC compiler, always/usr/local/ARM/4.3.2/bin /.. /lib/GCC/ARM-None-Linux-gnueabi/4.3.2 /.. /.. /.. /.. /ARM-None-Linux-gnueabi/bin/ld: Warning :.. /.. /lib/libcxcore. so, needed by/usr/local/ARM/opencv-2.1/lib/libcv. so,
Not found (try using-rpath or-rpath-link)
/Usr/local/ARM/4.3.2/bin /.. /lib/GCC/ARM-None-Linux-gnueabi/4.3.2 /.. /.. /.. /.. /ARM-None-Linux-gnueabi/bin/ld: Warning :.. /.. /lib/libcv. so, needed by/usr/local/ARM/opencv-2.1/lib/libcvaux. so, not found (try using-rpath or-rpath-link)
/Usr/local/ARM/4.3.2/bin /.. /lib/GCC/ARM-None-Linux-gnueabi/4.3.2 /.. /.. /.. /.. /ARM-None-Linux-gnueabi/bin/ld: Warning :.. /.. /lib/libhighgui. so, needed by/usr/local/ARM/opencv-2.1/lib/libcvaux. so, not found (try using-rpath or-rpath-link)
/Usr/local/ARM/4.3.2/bin /.. /lib/GCC/ARM-None-Linux-gnueabi/4.3.2 /.. /.. /.. /.. /ARM-None-Linux-gnueabi/bin/ld: Warning :.. /.. /lib/libml. so, needed by/usr/local/ARM/opencv-2.1/lib/libcvaux. so, not found (try using-rpath or-rpath-link)

An error occurred! Add export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/usr/local/ARM/opencv/lib to/etc/profile, and then source/etc/profile. gedit/etc/lD. so. conf also includes/usr/local/ARM/opencv/include/opencv, and ldconfig is still unavailable! Finally found/usr/local/ARM/qte-4.8.0/mkspec/default/qmake. conf, modify this file, add: cppflags = "-I
/Usr/local/ARM/opencv/include/opencv"
Ldflags = "-l/usr/local/ARM/opencv/lib ".... Still running! Copy these five. So files to the related directory of the cross compiler! Finally, I want to modify the makefile and change the original

Libs = $ (sublibs)-L/usr/local/ARM/qte-4.8.0/lib/usr/local/ARM/opencv/lib/libcv. so/usr/local/ARM/opencv/lib/libcvaux. so/usr/local/ARM/opencv/lib/libcxcore. so/usr/local/ARM/opencv/lib/libhighgui. so/usr/local/ARM/opencv/lib/libml. so-lqtgui
-L/usr/local/ARM/qte-4.8.0/lib-lqtnetwork-lqtcore-lpthread, think this sentence has a problem, change it:

Libs = $ (sublibs) -L/usr/local/ARM/qte-4.8.0/lib-lqtgui-L/usr/local/ARM/qte-4.8.0/lib-lqtnetwork-lqtcore-L/usr/local/ARM/opencv /lib-lml-lcvaux-lhighgui-LCV-lcxcore-lpthread

I thought the format is correct, but still not found (try using-rpath or-rpath-link )! My day !!! Finally reference http://blog.sina.com.cn/s/blog_602f87700100nyda.html

Http://blog.sina.com.cn/s/blog_602f87700100fbm3.html and http://www.cnblogs.com/s_agapo/archive/2011/11/24/2262346.html

, Add in makefile: lflags =-wl,-O1-wl,-rpath,/usr/local/ARM/qte-4.8.0/lib:-wl,-O1-wl, -rpath,/usr/local/ARM/opencv/lib think this is good. Who knows it is still wrong! Hit me! Directly decide to port opencv2.0 and pull down. Refer to http://blog.csdn.net/chennxi/article/details/6082039. my configuration is :./configure -- Host = arm-Linux -- without-GTK.
-- Without-carbon -- without-QuickTime -- without-1394libs -- without-FFMPEG -- without-Python -- without-swig -- enable-static -- enable-shared -- disable-apps cxx = arm-Linux- g ++ cppflags =-I/usr/local/ARM/4.3.2/ARM-None-Linux-gnueabi/include ldflags =-L/usr/local/ARM/4.3.2/ARM- none-Linux-gnueabi/libc/lib
-- With-v4l2 -- prefix =/usr/local/ARM/opencv -- libdir =/usr/local/ARM/opencv/lib-includedir =/usr/local/ARM/opencv/include

After the installation is complete, first compile the test above in the NFS test. c file, arm-Linux-GCC test. c-o Test-arm-I/usr/local/ARM/opencv/include/opencv-L/usr/local/ARM/opencv/lib-lml-lcvaux-lhighgui-LCV -lcxcore-lpthread-LRT compiled, copy the executable file to the board and run it. A message indicating that libcv is not displayed. So, remember to add the environment variable:

Export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/usr/local/ARM/opencv/lib. Run./test-arm and you will be prompted about the unsupported highgui functions, such as GTK! That's right!

Tip: during cross-compiling on PC Linux, be sure to specify-I/usr/local/ARM/opencv/include/opencv-L/usr/local/ARM/opencv/lib-lml-lcvaux-lhighgui-LCV-lcxcore, even if you set LD_LIBRARY_PATH, if you do not add this-I and-l, errors will still occur. If LD_LIBRARY_PATH is not set, you only need to specify-I and-l !!!

(3) If NFS is not used, copy lib and include under opencv to the same directory. During the copy operation, the file cannot be found. so, this is because the shortcut cannot be found during the copy using the CP command. There are two solutions: 1. change the so file name. For example, if you are prompted that libcv cannot be found. so, you find in the Board that there is no libcv. so, only libcv. so.4.0. You can view libcv on your PC. so libcv. so.4 and Lib. the first two files in so.4.0 are shortcuts. Use the LS-Al command to view libcv. so points to libcv. so.4.0, the super terminal connected to the board, CD to the lib directory,
Use ln-s libcv. so.4.0 (old name) libcv. So (new name, shortcut)

You can! 2. directly change the name of MV libcv. so.4.0 libcv. So!

(4) So far, we review why not found (try using-rpath or-rpath-link) can only be an explanation, the. So file arm-linux-gcc-4.3.2 made under cmake2.8.5 is not recognized! Refer to Region:-Wl,-rpath-Link
-Wl ,/.. ,... /... (Lib directory!

(5) the correct format of makefile generated by qmake is libs =$ (sublibs) -L/usr/local/ARM/qte-4.8.0/lib/usr/local/ARM/opencv/lib/libcv. so/usr/local/ARM/opencv/lib/libcvaux. so
/Usr/local/ARM/opencv/lib/libcxcore. so/usr/local/ARM/opencv/lib/libhighgui. so/usr/local/ARM/opencv/lib/libml. so-lqtgui-L/usr/local/ARM/qte-4.8.0/lib-lqtnetwork-lqtcore-lpthread! This is okay! You only need to add the following in the. Pro file:

Includepath + =/usr/local/ARM/opencv/include/opencv
Libs + =/usr/local/ARM/opencv/lib/libcv. So \
/Usr/local/ARM/opencv/lib/libcvaux. So \
/Usr/local/ARM/opencv/lib/libcxcore. So \
/Usr/local/ARM/opencv/lib/libhighgui. So \
/Usr/local/ARM/opencv/lib/libml. So

That's it! In addition, when setting export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/usr/local/ARM/opencv/lib, if your opencv compilation is correct, you only need these two additional settings, and QT can use opencv! All others are redundant!

(6) No test program for using opencv in QT is available on the Internet. I provide a code here to read a function using cvloadimage, convert the iplimage format to qimage format, and display it. The image path is/Ayan/r3.jpeg. You can create a folder named ayanin the root directory and copy r3.jpeg to the folder.
Perform the following operations on the arm board. Set export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/usr/local/ARM/opencv/lib before running! I will upload .....

Some questions:

1. I set the environment variable export qtdir =/usr/local/ARM/qte-4.8.0 when porting QT.

Export LD_LIBRARY_PATH = $ qtdir/lib:/usr/local/ARM/opencv-2.1/lib: $ LD_LIBRARY_PATH
Export qt_qws_fontdir =/usr/local/ARM/qte-4.8.0/lib/Fonts
Export qws_display = 'linuxfb: mmwidth76: mmheight44: 1'

However, in subsequent QT testing programs, I did not set these environment variable programs to run as usual! I run the Env command to check whether the settings of these variables are true. But when using opencv, you must set the lib directory of opencv! Why ???

(2) preview the video with opencv on the arm board. Although the video passes through on the PC, an error occurs on the board, which hurts! Segment error! I used Feiling's 6410 to play the video. Do I need to transplant Xvid and FFMPEG ??

(3) Can GTK be transplanted to arm6410 ??


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.