Build Opencv2.4.11 from source on RHEL 6.6
I'm trying to build Opencv 2.4.11 on RHEL 6.6 server. I can build the source without the python bindings, but if I include the python bindings the compile crashes. For some reason the build ignores the cmake settings and tries to include files from wrong location. Can anyone tell me how to get the python bindings to work? I have tried to build different versions of opencv for two weeks now and it really feels impossible(on ubuntu it builds just fine), I would really appreciate some help.
Here is my build setup(After running the script check that the CMakeCache.txt that the paths have the values that you set):
#!/bin/bash
export PYTHON_EXECUTABLE=/home/lato/karjaljo/sandbox/OCV2.4/venv/bin/python
export PYTHON_INCLUDE_PATH=/home/lato/karjaljo/sandbox/OCV2.4/venv/include/python2.7/
export PYTHON_LIBRARY=/home/lato/karjaljo/sandbox/OCV2.4/venv/lib64/libpython2.7.so
export PYTHON_NUMPY_INCLUDE_DIR=/home/lato/karjaljo/sandbox/OCV2.4/venv/lib64/python2.7/site-packages/numpy
export PYTHON_PACKAGES_PATH=/home/lato/karjaljo/sandbox/OCV2.4/venv/lib64/python2.7/site-packages
cmake \
-D CMAKE_INSTALL_PREFIX=/home/lato/karjaljo/sandbox/OCV2.4/ocv_with_python \
-D BUILD_opencv_python3=OFF \
-D BUILD_opencv_python=ON \
-DBUILD_DOCS=OFF \
-DBUILD_EXAMPLES=OFF \
-DBUILD_JPEG=OFF \
-DBUILD_OPENEXR=OFF \
-DBUILD_PACKAGE=OFF \
-DBUILD_PERF_TESTS=OFF \
-DBUILD_PNG=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TBB=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_TIFF=OFF \
-DBUILD_WITH_DEBUG_INFO=OFF \
-DBUILD_ZLIB=OFF \
-DWITH_1394=ON \
-DWITH_EIGEN=ON \
-DWITH_FFMPEG=OFF \
-DWITH_GIGEAPI=ON \
-DWITH_GSTREAMER=ON \
-DWITH_GTK=ON \
-DWITH_IPP=OFF \
-DWITH_JASPER=ON \
-DWITH_JPEG=ON \
-DWITH_LIBV4L=ON \
-DWITH_OPENCL=OFF \
-DWITH_OPENCLAMDBLAS=OFF \
-DWITH_OPENCLAMDFFT=OFF \
-DWITH_OPENEXR=OFF \
-DWITH_OPENGL=OFF \
-DWITH_OPENMP=OFF \
-DWITH_OPENNI=OFF \
-DWITH_PNG=ON \
-DWITH_PVAPI=OFF \
-DWITH_QT=OFF \
-DWITH_TBB=OFF \
-DWITH_TIFF=ON \
-DWITH_UNICAP=OFF \
-DWITH_V4L=OFF \
-DWITH_XIMEA=OFF \
-DWITH_XINE=OFF \
-DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
-DPYTHON_INCLUDE_PATH=$PYTHON_INCLUDE_PATH \
-DPYTHON_LIBRARY=$PYTHON_LIBRARY \
-DPYTHON_NUMPY_INCLUDE_DIR=$PYTHON_NUMPY_INCLUDE_DIR \
-DPYTHON_PACKAGES_PATH=$PYTHON_PACKAGES_PATH \
-Wno-dev ../
And the error
Building CXX object modules/contrib/CMakeFiles/opencv_contrib.dir/src/spinimages.cpp.o
[ 99%] Building CXX object modules/contrib/CMakeFiles/opencv_contrib.dir/src/stereovar.cpp.o
Linking CXX static library ../../lib/libopencv_contrib.a
[ 99%] Built target opencv_contrib
[ 99%] [ 99%] Generating pyopencv_generated_funcs.h, pyopencv_generated_func_tab.h, pyopencv_generated_types.h, pyopencv_generated_type_reg.h, pyopencv_generated_const_reg.h
Generating generated0.i
Generated 377 functions
Note: Class Feature2D has more than 1 base class (not supported by Python C extensions)
Bases: cv::FeatureDetector, cv::DescriptorExtractor
Only the first base class will be used
Scanning dependencies of target opencv_python
[100%] Building CXX object modules/python/CMakeFiles/opencv_python.dir/src2/cv2.cpp.o
/home/users/karjaljo/sandbox/OCV2.4/opencv-2.4.11/modules/python/src2/cv2.cpp:6:20: error: Python.h: No such file or directory
In file included from /usr/include/numpy/ndarraytypes.h:7,
from /usr/include/numpy/ndarrayobject.h:17,
from /home/users/karjaljo/sandbox/OCV2.4/opencv-2.4.11/modules/python/src2/cv2.cpp:15:
/usr/include/numpy/npy_common.h:85:2: error: #error Must use Python with unicode enabled.
In file included from /usr/include/numpy/ndarraytypes.h:7,
from /usr/include/numpy/ndarrayobject.h:17,
from /home/users/karjaljo/sandbox/OCV2.4/opencv-2.4.11/modules/python/src2/cv2.cpp:15:
/usr/include/numpy/npy_common.h:731 ...
What does your cmake output look like?