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