Saturday, March 22, 2014

"Bus error: 10" Cont.


It seems the best option is to make cv again, so, lets get the latest version:

# in a nice place you want to do your clone:
git clone https://github.com/Itseez/opencv.git opencv
cd opencv
mkdir makethis; cd makethis 
 # select 2.4 branch:
Luiss-iMac:opencv Luis$ git branch -a
* master
  remotes/origin/2.4
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
Luiss-iMac:opencv Luis$ git checkout 2.4
#This installs the 32 bit version:
cmake -G "Unix Makefiles" -D CMAKE_OSX_ARCHITECTURES=i386 -D CMAKE_C_FLAGS=-m32 -D CMAKE_CXX_FLAGS=-m32 -D CMAKE_INSTALL_PREFIX=/usr/local -D PYTHON_EXECUTABLE:FILEPATH=/usr/local/bin/python2.7-32 -D INSTALL_PYTHON_EXAMPLES:BOOL=ON .. 
# for the 64 version:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local PYTHON_EXECUTABLE:FILEPATH=/usr/local/bin/python2.7 -D INSTALL_PYTHON_EXAMPLES:BOOL=ON ..  
make -j8
#Go a get a beer... 

 Success looks like:
BUILD SUCCESSFUL
Total time: 5 seconds
[100%] Built target opencv_test_java 
sudo make install
Now, you might think that it's done:

Luiss-iMac:make5 Luis$ python2.7-32
Python 2.7.5 (v2.7.5:ab05e7dd2788, May 13 2013, 13:18:45)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/cv.py", line 1, in <module>
    from cv2 import *
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/cv2.so, 2): Symbol not found: __ZN2cv10PCAComputeERKNS_11_InputArrayERKNS_12_OutputArrayES5_d
  Referenced from: /usr/local/lib/python2.7/site-packages/cv2.so
  Expected in: lib/libopencv_core.3.0.dylib
 in /usr/local/lib/python2.7/site-packages/cv2.so
What's wrong now? well, this is an old fight I had with opencv, I managed to repel the enemy by:

          export DYLD_LIBRARY_PATH=/usr/opencv/lib/ 

That is, tell the Dynamic Linker

https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/dyld.1.html


Where to find the libs needed for cv2.so, how to find it?:

Luiss-iMac:site-packages Luis$ otool -L cv2.so

\cv2.so:

     cv2.so (compatibility version 0.0.0, current version 0.0.0)

     /System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.2)
     lib/libopencv_core.2.4.dylib (compatibility version 2.4.0, current version 2.4.7)

After this (you can include the env in your profile), and remember to use python-32 if you have installed OpenCV in 32 bits, you can use cv again:

Luiss-iMac:site-packages Luis$ python-32
Python 2.7.5 (v2.7.5:ab05e7dd2788, May 13 2013, 13:18:45)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv
>>>


EDIT:
An updated version on how to (re-)install OpenCv and/or set your DYLD_LIBRARY_PATH can be found here.

No comments:

Post a Comment