Build OpenCV error

我在編譯 OpenCV-2.3.1 for python 時遇到下面的錯誤

錯誤一:Linking error
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON -D  PYTHON_INCLUDE_DIR=/usr/local/include/python2.6 -D PYTHON_LIBRARY=/usr/local/lib/libpython2.6.a ..
/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libpython2.7.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [lib/cv2.so] Error 1
make[1]: *** [modules/python/CMakeFiles/opencv_python.dir/all] Error 2
make: *** [all] Error 2

解決方法就是重新編譯 python 加上 --enable-shared 的參數...找了好久lol
$ ./configure --enable-shared && make && make install

錯誤二:在 python 內找不到 cv module
Python 2.6.7 (r267:88850, Mar 20 2012, 11:54:21) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv
Traceback (most recent call last):
  File "stdin", line 1, in module
ImportError: No module named cv

InstallGuide 得知解決方法:
1. 把cv.so和cv2.so copy到
2. 增加path到PYTHONPATH
export PYTHONPATH=~/projects/opencv/release/lib:$PYTHONPATH