It's always a problem to toss this whole day yesterday. Today, we finally found an English installation guide. Follow that step-by-step installation, very smoothly installed OPENCV2.4.3+FFMEPG. To summarize, the methods mentioned in yesterday's blog mainly have two problems that ultimately lead to failure:
1. Under 64-bit systems, configuring external libraries such as x264 requires the use of-fpic tags for configure
./configure--enable-shared--enable-pic
2. Under 64-bit systems, when configuring FFmpeg, you do not need to add-fpic, but you need to set the-enable-shared
Therefore, you can uninstall the existing ffmpeg and reconfigure the installation as follows. Methods derived from http://www.ozbotz.org/opencv-installation/
If you still have a problem, you can refer to another question-answering post: http://ozbotz.org/opencv-install-troubleshooting/
--------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------
The installation Procedure
To install and configure OpenCV 2.4.1, complete the following steps. The commands shown in each step can copy and pasted directly to a Linux command line.
Recommend using OpenCV2.4.10 or higher version if using CUDA-6.5 or higher.
Remove any installed versions of FFmpeg and x264.
sudo apt-get remove ffmpeg x264 libx264-dev
Get all the dependencies for x264 and FFmpeg.
sudo apt-get update
sudo apt-get install build-essential checkinstall git cmake libfaac-dev libjack-jackd2-dev libmp3lame-dev Libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev Libvorbis-dev Libx11-dev libxfixes-dev Libxvidcore-dev texi2html yasm Zlib1g-dev
Download and install GStreamer.
sudo apt-get install libgstreamer0.10-0 libgstreamer0.10-dev gstreamer0.10-tools gstreamer0.10-plugins-base Libgstreamer-plugins-base0.10-dev Gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly Gstreamer0.10-plugins-bad Gstreamer0.10-ffmpeg
Download and install GTK.
sudo apt-get install libgtk2.0-0 Libgtk2.0-dev
Download and install Libjpeg.
sudo apt-get install Libjpeg8 Libjpeg8-dev
Create a directory to hold source code.
CD ~
mkdir SRC
Download and install install x264.
Download A recent stable snapshot of x264 from ftp://ftp.videolan.org/pub/videolan/x264/snapshots/. The exact version does not seem to matter. To write the This guide, I used version x264-snapshot-20120528-2245-stable.tar.bz2, but I had used previous versions too.
CD ~/SRC
wget ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20120528-2245-stable.tar.bz2
Tar xvf x264-snapshot-20120528-2245-stable.tar.bz2
CD x264-snapshot-20120528-2245-stable
Configure and build the x264 libraries.
./configure--enable-static
Make
sudo make install
Important:if you is running a 64-bit version of Ubuntu, you must configure x264 as shown in the following command:
./configure--enable-shared--enable-pic
the-shared and-pic options might also be required when you compile for some other architectures, such as ARM. You know need these options if your get the following error when compiling OpenCV:
[25%] Building CXX Object MODULES/HIGHGUI/CMAKEFILES/OPENCV_HIGHGUI.DIR/SRC/BITSTRM.CPP.O
Linking CXX shared library. /.. /lib/libopencv_highgui.so
/USR/BIN/LD:/USR/LOCAL/LIB/LIBAVCODEC.A (AVPACKET.O): Relocation r_x86_64_32s against ' av_destruct_packet ' can not be Used when making a shared object; Recompile with-fpic/usr/local/lib/libavcodec.a:could not read Symbols:bad value
Download and install install FFmpeg.
Download ffmpeg version 0.11.x from http://ffmpeg.org/download.html.
CD ~/SRC
wget http://ffmpeg.org/releases/ffmpeg-0.11.tar.bz2
Tar xvf ffmpeg-0.11.tar.bz2
CD ffmpeg-0.11
Configure and build FFmpeg.
./configure--ENABLE-GPL--ENABLE-LIBFAAC--enable-libmp3lame--enable-libopencore-amrnb--ENABLE-LIBOPENCORE-AMRWB --enable-libtheora--enable-libvorbis--enable-libx264--enable-libxvid--enable-nonfree--enable-postproc-- Enable-version3--enable-x11grab
Make
sudo make install
Important:just like with x264 in the previous step, you must configure FFmpeg with THE-SHARED option if you are running A 64-bit version of Ubuntu or some other architectures, such as ARM. The-pic option is not a necessary for ffmpeg.
./configure--ENABLE-GPL--ENABLE-LIBFAAC--enable-libmp3lame--enable-libopencore-amrnb--ENABLE-LIBOPENCORE-AMRWB --enable-libtheora--enable-libvorbis--enable-libx264--enable-libxvid--enable-nonfree--enable-postproc-- Enable-version3--enable-x11grab--enable-shared
If after make install, appear error:mkdir:cannot create directory '/usr/local/share/man/man1 ': File exists, referhttp:// blog.csdn.net/kaka20080622/article/details/40260369
If input ffmpeg and occurs error:Ffmpeg:error while loading shared libraries:Libavdevice. So.52:cannot open shared object, refer http://blog.csdn.net/kaka20080622/article/details/40260423
Download and install install a recent version of V4L (video for Linux) from http://www.linuxtv.org/downloads/v4l-utils/. For this guide I used version 0.8.8.
CD ~/SRC
wget http://www.linuxtv.org/downloads/v4l-utils/v4l-utils-0.8.8.tar.bz2
Tar xvf v4l-utils-0.8.8.tar.bz2
CD v4l-utils-0.8.8
Make
sudo make install
Download and install install OpenCV 2.4.1.
Download OpenCV version 2.4.1 from http://sourceforge.net/projects/opencvlibrary/files/
CD ~/SRC
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.1/OpenCV-2.4.1.tar.bz2
Tar xvf opencv-2.4.1.tar.bz2
Create a new build directory and run CMake:
CD OPENCV-2.4.1/
mkdir Build
CD Build
Cmake-d Cmake_build_type=release.
Verify that the output of CMake includes the following text:
Found gstreamer-base-0.10
GTK + 2.x:yes
Ffmpeg:yes
Gstreamer:yes
V4l/v4l2:using libv4l
Build and install OpenCV.
Make
sudo make install
Note:if using CUDA-6.5, then compile opencv2.4.9 or below, an ERROR:GPU/SRC/NVIDIA/CORE/NCVPIXELOPERATIONS.HPP (): Erro R:A storage class is isn't allowed in a explicit specialization, solution for the is to using higher version of OpenCV, S Uch as opencv.2.4.10 or opencv3.0
Configure Linux.
Tell Linux where the GKFX libraries for OpenCV is located by entering the following shell command:
Export Ld_library_path=/usr/local/lib
ADD the command to your. bashrc file so, you do not have to enter every time your start a new terminal.
Alternatively, you can configure the System wide Library search path. Using your favorite editor, add a single line containing the text
/usr/local/lib to the end of a file named/etc/ld.so.conf.d/opencv.conf
. In the "Ubuntu install", the opencv.conf file does not exist; You need to create it. Using VI, for example, enter the following commands:
sudo vi/etc/ld.so.conf.d/opencv.conf
G
O
/usr/local/lib
<Esc>
: wq!
After editing the opencv.conf file, enter the following command:
sudo ldconfig/etc/ld.so.conf
.
Using your favorite editor, add the following the lines to the end OF/ETC/BASH.BASHRC:
Pkg_config_path= $PKG _config_path:/usr/local/lib/pkgconfig
Export Pkg_config_path
After completing the previous steps, your system should is ready for compile code that uses the OpenCV libraries. The following example shows one-to-compile code for OpenCV:
g++ ' pkg-config opencv--cflags ' my_code.cpp-o my_code ' pkg-config OpenCV--libs