29 Aralık 2014 Pazartesi

Undefined reference to symbol 'v4l2_munmap' error while installing OpenCV 2.4.9 on Ubuntu 14.04

If you are dealing with image processing in one of your projects, almost all roads lead to OpenCV and Tesseract. Tesseract is a OCR library created by HP and currently is handled by Google. In order to get good results in OCR process, you need to preprocess your image for OCR. For this, you can use OpenCV image processing library. Maybe installing OpenCV in various platforms might be very easy but installing it on Ubuntu is a living hell.

There are plenty of guides and resources about installing OpenCV on Ubuntu. I tried most of them but every time I got the same error: " Undefined reference to symbol 'v4l2_munmap' ". Before installing OpenCV, some other packages must be installed on Ubuntu which you can find everywhere. If you install required packages and still got the same error, there is a solution.

Possibly, you get the error message below:

/usr/bin/ld: ../../lib/libopencv_highgui.a(cap_libv4l.cpp.o): undefined reference to symbol 'v4l2_munmap'
//usr/lib/x86_64-linux-gnu/libv4l2.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make2: * [bin/opencv_test_highgui] Error 1
make1: [modules/highgui/CMakeFiles/opencv_test_highgui.dir/all] Error 2
make: ** [all] Error 2

To overcome this problem, all you need is to append " -lv4l2 " to [OPENCV_BUILD_DIR]/modules/highgui/CMakeFiles/opencv_test_highgui.dir/link.txt

After making the change, you need to execute make command again. Possibly, you will get the same error with different file names. All you need to do is applying same process to all files which gives the same error. For example if you see " modules/superres/CMakeFiles/opencv_test_superres.dir/all " near Error 2, you need to append " -lv4l2 " to [OPENCV_BUILD_DIR]/modules/superres/CMakeFiles/opencv_test_superres.dir/link.txt.

Unfortunately, you will get this error in more than 50 files. Of course more elegant solution is to detect these files and append " -lv4l2 " to all of them before starting make process.

By the way, if you want to compile OpenCV without bothering required packages or other things, there is a simple .sh file which handles all of these processes. You can download it from the link below and run the file to complete installation easily.


( opencv 2.4.9, tesseract, ubuntu 14.04, compile error, DSO missing from command line, -lv4l2 )
OpenCV installation script: https://github.com/jayrambhia/Install-OpenCV/tree/master/Ubuntu 
Reference: http://code.opencv.org/issues/3726

Hiç yorum yok:

Yorum Gönder