如本错误报告中所述,问题是 cmake 的旧版本(2.8.2)。所以解决方案是获取 cmake 源的新副本,编译它并使用它来安装 OpenCV。
注意 18/09/2012:这也适用于带有 cmake 2.8.9 的 Ubuntu 12.04!
# get the cmake src
wget http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz
# extract archive
tar xfvz cmake-2.8.8.tar.gz
# build the new version
cd cmake-2.8.8
cmake .
make
sudo make install
# get the OpenCV src
wget -O OpenCV-2.4.2.tar.bz2 http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.2/OpenCV-2.4.2.tar.bz2/download
# extract it …
tar -xvf OpenCV-2.4.2.tar.bz2
# build it
mkdir build
cd build
/usr/local/bin/cmake -D CMAKE_BUILD_TYPE=RELEASE ..
make
sudo make install
# setup OpenCV
sudo echo “/usr/local/lib” >> /etc/ld.so.conf
sudo ldconfig
而已。