Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac OSX 10.11.x #67

Closed
illume opened this issue Feb 17, 2018 · 5 comments
Closed

Mac OSX 10.11.x #67

illume opened this issue Feb 17, 2018 · 5 comments

Comments

@illume
Copy link
Contributor

illume commented Feb 17, 2018

Expected behaviour

Module should import.

Actual behaviour

A symbol error happens when trying to import.

Steps to reproduce

Mac OSX 10.11.6

cd /tmp/
13:49:52-rene/tmp/opencv$     python3 -m venv anenv
13:49:55-rene/tmp/opencv$     . ./anenv/bin/activate
(anenv) 13:49:55-rene/tmp/opencv$     pip install opencv-python
Collecting opencv-python
  Downloading opencv_python-3.4.0.12-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (41.2MB)
    100% |████████████████████████████████| 41.2MB 38kB/s 
Collecting numpy>=1.11.1 (from opencv-python)
  Using cached numpy-1.14.0-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Installing collected packages: numpy, opencv-python
Successfully installed numpy-1.14.0 opencv-python-3.4.0.12
(anenv) 13:50:57-rene/tmp/opencv$ pip install numpy
Requirement already satisfied: numpy in ./anenv/lib/python3.6/site-packages
(anenv) 13:57:36-rene/tmp/opencv$ python
Python 3.6.0 (default, Dec 24 2016, 00:01:50) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/private/tmp/opencv/anenv/lib/python3.6/site-packages/cv2/__init__.py", line 4, in <module>
    from .cv2 import *
ImportError: dlopen(/private/tmp/opencv/anenv/lib/python3.6/site-packages/cv2/cv2.cpython-36m-darwin.so, 2): Symbol not found: _clock_gettime
  Referenced from: /private/tmp/opencv/anenv/lib/python3.6/site-packages/cv2/.dylibs/libavutil.55.78.100.dylib (which was built for Mac OS X 10.12)
  Expected in: /usr/lib/libSystem.B.dylib
 in /private/tmp/opencv/anenv/lib/python3.6/site-packages/cv2/.dylibs/libavutil.55.78.100.dylib
>>> import platform
>>> platform.platform()
'Darwin-15.6.0-x86_64-i386-64bit'

I guess opencv should work ok on 10.11? I use it through homebrew at least.

In https://github.com/pygame/pygame we use osx_image: xcode7.3 for our mac wheels, and get 10.11 support.

@skvark
Copy link
Member

skvark commented Feb 17, 2018

This is not related to OpenCV. The error comes from libavutil (=FFmpeg) which is installed via homebrew. The error is related to binary backward compatibility (apparently Apple has changed the libsystem interface). I'm not too familiar with Apples ecosystem but building FFmpeg against earlier OS version might fix the issue if the older symbols are present also in the latest OS versions. Full backward compatibility on macOS might be impossible to achieve.

@illume
Copy link
Contributor Author

illume commented Feb 17, 2018

I think if you use the home brew dependencies from the xcode7.3 image it would work on newer versions of Mac OS as well.

The table here shows which Mac OS version each travis image is compiled to support:
https://docs.travis-ci.com/user/reference/osx/#OS-X-Version

In testing I've done with other libs the xcode7.3 image homebrew stuff works quite widely.

@droe
Copy link

droe commented Mar 29, 2018

I was just bitten by this issue the hard way deep in nested dependencies; FFmpeg targets 10.12 but I'm on 10.11. Hoping for a fixed release soon.

Note that while downgrading Xcode may work too, the proper way to target an earlier version of macOS is to add e.g. -mmacosx-version-min=10.11 or -mmacosx-version-min=10.6 to CFLAGS/CXXFLAGS/LDFLAGS; this will tune headers, compiler and linker to produce a binary that is compatible with at least that version of macOS.

@skvark
Copy link
Member

skvark commented Mar 29, 2018

Yeah, I will do a release as soon as #82 has been fixed. Looks like -mmacosx-version-min can be set for Cmake with MACOSX_DEPLOYMENT_TARGET. I will add the flag. However, as the issue is with FFmpeg and not with OpenCV, the flag doesn't have any effect on FFmpeg build which is installed via Homebrew. The older Travis image (xcode7.3) should make it work.

@droe
Copy link

droe commented Mar 29, 2018

Thanks for elaborating and thanks for working on the next release.

Sounds to me like the solution would be to configure Homebrew to use additional CFLAGS/CXXFLAGS/LDFLAGS when building FFmpeg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants