Installing OpenCV on Ubuntu 12.04

I am trying to install OpenCV 2.4.2 on Ubuntu and am confusing errors as shown below:

[ 11%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_gtk.cpp.o In file included from /usr/local/include/glib-2.0/glib/gasyncqueue.h:30:0, from /usr/local/include/glib-2.0/glib.h:32, from /usr/local/include/gtk-2.0/gdk/gdktypes.h:32, from /usr/local/include/gtk-2.0/gdk/gdkcolor.h:4, from /usr/local/include/gtk-2.0/gdk/gdk.h:30, from /usr/local/include/gtk-2.0/gtk/gtk.h:31, from /opt/opencv/OpenCV-2.4.2/modules/highgui/src/window_gtk.cpp:48: /usr/local/include/glib-2.0/glib/gthread.h:233:27: error: variable or field 'g_static_mutex_init' declared void /usr/local/include/glib-2.0/glib/gthread.h:233:27: error: 'GStaticMutex' was not declared in this scope /usr/local/include/glib-2.0/glib/gthread.h:233:41: error: 'mutex' was not declared in this scope /usr/local/include/glib-2.0/glib/gthread.h:233:41: note: suggested alternative: /usr/include/tbb/mutex.h:48:7: note: 'tbb::mutex' 

I checked all the dependencies and installed them as shown below:

 sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen2-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev 

I also added the following paths to CMakeCache.txt

 CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG -I/usr/lib/x86_64-linux-gnu/glib-2.0/include/ -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include/ 

Any help is appreciated.

Thanks,

Sid

Edit: I switched to QT according to the comment and let me get rid of gtk by including in it what I had to manually insert into CMakeCache.txt. But I was still getting the installation error (possibly due to glib being turned on), so I disabled GSTREAMER in CMAKE, and now I can install opencv. Is this work possible?

+3
source share
2 answers

Curiously, you need v2.4.2 when v2.4.9 is the latest version. In any case, following the steps, the configuration report is displayed before the make step, which looks like this:

 -- -- General configuration for OpenCV 2.4.2 ===================================== -- -- Platform: -- Host: Linux 3.8.0-29-generic x86_64 -- CMake: 2.8.7 -- CMake generator: Unix Makefiles -- CMake build tool: /usr/bin/make -- Configuration: RELEASE -- -- C/C++: -- Built as dynamic libs?: YES -- C++ Compiler: /usr/bin/c++ (ver 4.6.3) -- C++ flags (Release): -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -O3 -DNDEBUG -DNDEBUG -- C++ flags (Debug): -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -g -O0 -DDEBUG -D_DEBUG -ggdb3 -- C Compiler: /usr/bin/gcc -- C flags (Release): -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -O3 -DNDEBUG -DNDEBUG -- C flags (Debug): -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -g -O0 -DDEBUG -D_DEBUG -ggdb3 -- Linker flags (Release): -- Linker flags (Debug): -- Precompiled headers: NO -- -- OpenCV modules: -- To be built: core imgproc flann highgui features2d calib3d ml video objdetect contrib nonfree gpu legacy photo python stitching ts videostab -- Disabled: - -- Disabled by dependency: - -- Unavailable: androidcamera java world -- -- GUI: -- QT 4.x: NO -- GTK+ 2.x: YES (ver 2.24.10) -- GThread : YES (ver 2.32.4) -- GtkGlExt: NO -- OpenGL support: NO -- -- Media I/O: -- ZLib: /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.3.4) -- JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so (ver ) -- PNG: /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.46) -- TIFF: /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 3.9.5) -- JPEG 2000: /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1) -- OpenEXR: /usr/lib/libImath.so /usr/lib/libIlmImf.so /usr/lib/libIex.so /usr/lib/libHalf.so /usr/lib/libIlmThread.so (ver 1.6.1) -- -- Video I/O: -- DC1394 1.x: NO -- DC1394 2.x: YES (ver 2.2.0) -- FFMPEG: YES -- codec: YES (ver 53.35.0) -- format: YES (ver 53.21.1) -- util: YES (ver 51.22.2) -- swscale: YES (ver 2.1.0) -- gentoo-style: YES -- GStreamer: NO -- OpenNI: NO -- OpenNI PrimeSensor Modules: NO -- PvAPI: NO -- UniCap: NO -- UniCap ucil: NO -- V4L/V4L2: Using libv4l (ver 0.8.6) -- XIMEA: NO -- Xine: NO -- -- Other third-party libraries: -- Use IPP: NO -- Use TBB: NO -- Use Cuda: NO -- Use Eigen: YES (ver 2.0.17) -- -- Python: -- Interpreter: /usr/bin/python (ver 2.7.3) -- Libraries: /usr/lib/libpython2.7.so -- numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.6.1) -- packages path: lib/python2.7/dist-packages -- -- Documentation: -- Build Documentation: YES -- Sphinx: /usr/bin/sphinx-build (ver 1.1.3) -- PdfLaTeX compiler: /usr/bin/pdflatex -- -- Tests and samples: -- Tests: YES -- Performance tests: YES -- Examples: NO -- -- Install path: /usr/local -- -- cvconfig.h is in: /home/vagrant/OpenCV-2.4.2/release -- ----------------------------------------------------------------- -- -- Configuring done -- Generating done -- Build files have been written to: /home/vagrant/OpenCV-2.4.2/release 

Check this report for all missing libraries and install these dependencies.

I managed to create the source code and skip your error on ubuntu 12.04 by installing the dependencies you listed:

 ... [ 13%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/window.cpp.o [ 13%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_gtk.cpp.o [ 13%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_dc1394_v2.cpp.o [ 13%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_libv4l.cpp.o [ 14%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/grfmt_sunras.cpp.o [ 14%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/grfmt_pxm.cpp.o [ 14%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/grfmt_jpeg2000.cpp.o [ 14%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/grfmt_exr.cpp.o [ 14%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/grfmt_imageio.cpp.o [ 15%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/grfmt_jpeg.cpp.o [ 15%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/grfmt_base.cpp.o [ 15%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/grfmt_png.cpp.o [ 15%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/grfmt_bmp.cpp.o [ 15%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/grfmt_tiff.cpp.o [ 15%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/bitstrm.cpp.o Linking CXX shared library ../../lib/libopencv_highgui.so ... 
+1
source

If you do not need certain compilation options, you should be able to install OpenCV directly from Synaptic (version 2.3.1); libraries are already in the default repository.

If you need a newer version, you can also find some PPAs with pre-compiled OpenCV, for example https://launchpad.net/~yjwong/+archive/opencv2 or https://launchpad.net/~limparissoft/+archive/opencv -ppa

You can find more PPAs at https://launchpad.net/ubuntu/+ppas?name_filter=opencv

+1
source

All Articles