Invalid MEX function in MATLAB R2015a Mac OS
mzahana opened this issue ยท 35 comments
Hi,
I am trying to run an example to test opencv in MATLAB R2015a.
in MATLAB, I run,
detector = cv.CascadeClassifier('haarcascade_frontalface_alt.xml');
I get the following error,
Invalid MEX-file
'/Users/abdkadma/Dropbox/git/mexopencv/+cv/private/CascadeClassifier_.mexmaci64':
dlopen(/Users/abdkadma/Dropbox/git/mexopencv/+cv/private/CascadeClassifier_.mexmaci64,
6): Library not loaded:
/usr/local/opt/libtiff/lib/libtiff.5.dylib
Referenced from:
/usr/local/opt/opencv3/lib/libopencv_imgcodecs.3.1.dylib
Reason: Incompatible library
version:
libopencv_imgcodecs.3.1.dylib
requires version 8.0.0 or later,
but libtiff.5.dylib provides
version 6.0.0
Any hints?
@mzahana It's a dependency problem. You probably have multiple versions of libtiff
in the system. Update libtiff
to the latest version if possible (e.g., using port or homebrew). Do the following to identify which libtiff is offending.
otool -L /Users/abdkadma/Dropbox/git/mexopencv/+cv/private/CascadeClassifier_.mexmaci64
If, for any reason, you need to keep old incompatible libtiff
, set DYLD_INSERT_LIBRARIES
variable to force loading the newer libtiff
.
Thanks for the reply. Here is what I get when I run the otool
/Users/abdkadma/Dropbox/git/mexopencv/+cv/private/CascadeClassifier_.mexmaci64:
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 20.0.0)
/usr/local/opt/opencv3/lib/libopencv_shape.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/local/opt/opencv3/lib/libopencv_stitching.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/local/opt/opencv3/lib/libopencv_objdetect.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/local/opt/opencv3/lib/libopencv_superres.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/local/opt/opencv3/lib/libopencv_videostab.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/local/opt/opencv3/lib/libopencv_calib3d.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/local/opt/opencv3/lib/libopencv_features2d.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/local/opt/opencv3/lib/libopencv_highgui.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/local/opt/opencv3/lib/libopencv_videoio.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/local/opt/opencv3/lib/libopencv_imgcodecs.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/local/opt/opencv3/lib/libopencv_video.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/local/opt/opencv3/lib/libopencv_photo.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/local/opt/opencv3/lib/libopencv_ml.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/local/opt/opencv3/lib/libopencv_imgproc.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/local/opt/opencv3/lib/libopencv_flann.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/local/opt/opencv3/lib/libopencv_core.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
@rpath/libmx.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libmex.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
How can I update the libtiff
?
Thanks.
@mzahana Keep tracking the depenency untill you hit the offending object. In your case,
otool -L /usr/local/opt/opencv3/lib/libopencv_imgcodecs.3.1.dylib
If you can find a valid libtiff
path in the output above, specify that in DYLD_INSERT_LIBRARIES
to force pre-loading libtiff
when launching Matlab (c.f., Invalid MEX file).
I don't know how you can update libtiff
since you are installing OpenCV with source package and the dependency path does not look normal:
/usr/local/opt/libtiff/lib/libtiff.5.dylib
I usually recommend installing OpenCV with package manager like Macports or Homebrew to avoid any of the dependency issue. But you will perhaps need to go back to OpenCV compilation and installation options to make sure the OpenCV binary is linked to the right depenency.
Thanks for your help. I am starting to get dizzy on that ๐, but will keep trying.
Here is the output of the otool
:
/usr/local/opt/opencv3/lib/libopencv_imgcodecs.3.1.dylib:
/usr/local/opt/opencv3/lib/libopencv_imgcodecs.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/local/Cellar/opencv3/3.1.0_3/lib/libopencv_imgproc.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
/usr/local/opt/jpeg/lib/libjpeg.8.dylib (compatibility version 13.0.0, current version 13.0.0)
/usr/local/opt/libpng/lib/libpng16.16.dylib (compatibility version 38.0.0, current version 38.0.0)
/usr/local/opt/libtiff/lib/libtiff.5.dylib (compatibility version 8.0.0, current version 8.4.0)
/usr/local/opt/ilmbase/lib/libImath-2_2.12.dylib (compatibility version 13.0.0, current version 13.0.0)
/usr/local/opt/openexr/lib/libIlmImf-2_2.22.dylib (compatibility version 23.0.0, current version 23.0.0)
/usr/local/opt/ilmbase/lib/libIex-2_2.12.dylib (compatibility version 13.0.0, current version 13.0.0)
/usr/local/opt/ilmbase/lib/libHalf.12.dylib (compatibility version 13.0.0, current version 13.0.0)
/usr/local/opt/ilmbase/lib/libIlmThread-2_2.12.dylib (compatibility version 13.0.0, current version 13.0.0)
/usr/local/Cellar/opencv3/3.1.0_3/lib/libopencv_core.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
Any conclusions from that?
I could notice this:
/usr/local/opt/libtiff/lib/libtiff.5.dylib (compatibility version 8.0.0, current version 8.4.0)
Do I need to update anything?
@mzahana compare the output when you run otool
from inside MATLAB:
>> !otool -L ...
You will likely see that MATLAB loads its own libtiff library older than the one used when compiling OpenCV, in which case you need to force-load the newer one like kyamagu explained.
this is what i get when i run !otool
in MATLAB
/usr/local/opt/opencv3/lib/libopencv_imgcodecs.3.1.dylib:
/usr/local/opt/opencv3/lib/libopencv_imgcodecs.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/local/Cellar/opencv3/3.1.0_3/lib/libopencv_imgproc.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
/usr/local/opt/jpeg/lib/libjpeg.8.dylib (compatibility version 13.0.0, current version 13.0.0)
/usr/local/opt/libpng/lib/libpng16.16.dylib (compatibility version 38.0.0, current version 38.0.0)
/usr/local/opt/libtiff/lib/libtiff.5.dylib (compatibility version 8.0.0, current version 8.4.0)
/usr/local/opt/ilmbase/lib/libImath-2_2.12.dylib (compatibility version 13.0.0, current version 13.0.0)
/usr/local/opt/openexr/lib/libIlmImf-2_2.22.dylib (compatibility version 23.0.0, current version 23.0.0)
/usr/local/opt/ilmbase/lib/libIex-2_2.12.dylib (compatibility version 13.0.0, current version 13.0.0)
/usr/local/opt/ilmbase/lib/libHalf.12.dylib (compatibility version 13.0.0, current version 13.0.0)
/usr/local/opt/ilmbase/lib/libIlmThread-2_2.12.dylib (compatibility version 13.0.0, current version 13.0.0)
/usr/local/Cellar/opencv3/3.1.0_3/lib/libopencv_core.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
@mzahana What happens if you set DYLD_INSERT_LIBRARIES
variable when launching Matlab? Do you observe the same error?
DYLD_INSERT_LIBRARIES=/usr/local/opt/libtiff/lib/libtiff.5.dylib /Applications/MATLAB_R2015a.app/bin/matlab
still there i a problem:
Invalid MEX-file
'/Users/abdkadma/Dropbox/git/mexopencv/+cv/private/CascadeClassifier_.mexmaci64':
dlopen(/Users/abdkadma/Dropbox/git/mexopencv/+cv/private/CascadeClassifier_.mexmaci64,
6): Library not loaded:
/usr/local/opt/libtiff/lib/libtiff.5.dylib
Referenced from:
/usr/local/opt/opencv3/lib/libopencv_imgcodecs.3.1.dylib
Reason: Incompatible library version:
libopencv_imgcodecs.3.1.dylib requires
version 8.0.0 or later, but
libtiff.5.dylib provides version 6.0.0
Error in cv.CascadeClassifier (line 113)
this.id =
CascadeClassifier_(0, 'new');
@mzahana According to the otool
output, I suspect you have installed both source-built OpenCV and package-managed OpenCV and broke the dependency.
/usr/local/opt/opencv3/lib/libopencv_imgcodecs.3.1.dylib:
/usr/local/opt/opencv3/lib/libopencv_imgcodecs.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/local/Cellar/opencv3/3.1.0_3/lib/libopencv_imgproc.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
The /usr/local/Cellar
path is very likely a homebrew-version of the library. Can you remove the current OpenCV installation (make uninstall
in the source package, or brew uninstall opencv3
), install either one but not both, and re-compile mexopencv
?
Ok, I am doing that now.
Now, what is a clean way to install and compile Opencv3?
@mzahana I recommend Homebrew package. See the previous comment.
brew install homebrew/science/opencv3
OK. Here us what i got when i installed opencv3 using brew:
==> Installing opencv3 from homebrew/science
==> Downloading https://homebrew.bintray.com/bottles-science/opencv3-3.1.0_3.el_capitan.bottle.2.t
Already downloaded: /Library/Caches/Homebrew/opencv3-3.1.0_3.el_capitan.bottle.2.tar.gz
==> Pouring opencv3-3.1.0_3.el_capitan.bottle.2.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.
opencv3 and opencv install many of the same files.
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:
LDFLAGS: -L/usr/local/opt/opencv3/lib
CPPFLAGS: -I/usr/local/opt/opencv3/include
If you need Python to find bindings for this keg-only formula, run:
echo /usr/local/opt/opencv3/lib/python2.7/site-packages >> /usr/local/lib/python2.7/site-packages/opencv3.pth
==> Summary
๐บ /usr/local/Cellar/opencv3/3.1.0_3: 281 files, 119.9M
when i run LDFLAGS=-L/usr/local/Cellar/opencv3/3.1.0_3/share/OpenCV/3rdparty/lib/ MATLABDIR=/Applications/MATLAB_R2015a.app make -j4
or MATLABDIR=/Applications/MATLAB_R2015a.app make -j4
, i get the same error
Makefile:97: *** "OpenCV 3.x package was not found in the pkg-config search path". Stop.
Stil, same problem
LDFLAGS=-L/usr/local/Cellar/opencv3/3.1.0_3/share/OpenCV/3rdparty/lib/ PKG_CONFIG_OPENCV=opencv3 MATLABDIR=/Applications/MATLAB_R2015a.app make -j4
Makefile:97: *** "OpenCV 3.x package was not found in the pkg-config search path". Stop.
@mzahana Can you post the output of the following? Homebrew usually takes care of pkg-config
setup.
pkg-config --exists --atleast-version=3 opencv3
echo $?
pkg-config --cflags --libs opencv3
@mzahana If this doesn't work, you might need to force symlink.
brew link --force opencv3
The output as as follows:
pkg-config --exists --atleast-version=3 opencv3
kl-14887:mexopencv abdkadma$ echo $?
1
and
pkg-config --cflags --libs opencv3
Package opencv3 was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv3.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv3' found
and here is the output when I try brew link --force opencv3
sudo brew link --force opencv3
Linking /usr/local/Cellar/opencv3/3.1.0_3...
Error: Could not symlink lib/libopencv_calib3d.3.1.dylib
Target /usr/local/lib/libopencv_calib3d.3.1.dylib
already exists. You may want to remove it:
rm '/usr/local/lib/libopencv_calib3d.3.1.dylib'
To force the link and overwrite all conflicting files:
brew link --overwrite opencv3
To list all files that would be deleted:
brew link --overwrite --dry-run opencv3
I think i screwed my opencv build. I can not even make
opencv3 and re-install it.
When I download the opencv3 source and generate Makefile using make, then run make
inside the /build
folder, the make
stops at 53% and I get the following errors:
In file included from /Users/abdkadma/Dropbox/opencv-3.1.0/modules/videoio/src/cap_qtkit.mm:46:
In file included from /System/Library/Frameworks/QTKit.framework/Headers/QTKit.h:20:
In file included from /System/Library/Frameworks/QTKit.framework/Headers/QTError.h:17:
In file included from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:10:
In file included from /System/Library/Frameworks/Foundation.framework/Headers/NSArray.h:5:
/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:19:21: error:
expected a type
- (id)copyWithZone:(nullable NSZone *)zone;
^
/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:25:28: error:
expected a type
- (id)mutableCopyWithZone:(nullable NSZone *)zone;
^
/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:32:4: error:
expected a type
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder; // NS_DESIGN...
^
/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:53:4: error:
expected a type
- (nullable id)replacementObjectForCoder:(NSCoder *)aCoder;
^
/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:54:4: error:
expected a type
- (nullable id)awakeAfterUsingCoder:(NSCoder *)aDecoder NS_REPLACES_RECEIVER;
^
In file included from /Users/abdkadma/Dropbox/opencv-3.1.0/modules/videoio/src/cap_qtkit.mm:46:
In file included from /System/Library/Frameworks/QTKit.framework/Headers/QTKit.h:20:
In file included from /System/Library/Frameworks/QTKit.framework/Headers/QTError.h:17:
In file included from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:10:
In file included from /System/Library/Frameworks/Foundation.framework/Headers/NSArray.h:6:
/System/Library/Frameworks/Foundation.framework/Headers/NSEnumerator.h:7:15: error:
expected ';' after @class
@class NSArray<ObjectType>;
^
/System/Library/Frameworks/Foundation.framework/Headers/NSEnumerator.h:7:16: error:
cannot find protocol declaration for 'ObjectType'
@class NSArray<ObjectType>;
^
/System/Library/Frameworks/Foundation.framework/Headers/NSEnumerator.h:34:25: error:
cannot find protocol declaration for 'ObjectType'
@interface NSEnumerator<ObjectType> : NSObject <NSFastEnumeration>
^
/System/Library/Frameworks/Foundation.framework/Headers/NSEnumerator.h:34:37: error:
expected unqualified-id
@interface NSEnumerator<ObjectType> : NSObject <NSFastEnumeration>
^
/System/Library/Frameworks/Foundation.framework/Headers/NSEnumerator.h:36:4: error:
expected a type
- (nullable ObjectType)nextObject;
^
/System/Library/Frameworks/Foundation.framework/Headers/NSEnumerator.h:40:25: error:
cannot find protocol declaration for 'ObjectType'
@interface NSEnumerator<ObjectType> (NSExtendedEnumerator)
^
/System/Library/Frameworks/Foundation.framework/Headers/NSEnumerator.h:40:1: error:
duplicate interface definition for class 'NSEnumerator'
@interface NSEnumerator<ObjectType> (NSExtendedEnumerator)
^
/System/Library/Frameworks/Foundation.framework/Headers/NSEnumerator.h:34:12: note:
previous definition is here
@interface NSEnumerator<ObjectType> : NSObject <NSFastEnumeration>
^
/System/Library/Frameworks/Foundation.framework/Headers/NSEnumerator.h:40:37: error:
method type specifier must start with '-' or '+'
@interface NSEnumerator<ObjectType> (NSExtendedEnumerator)
^
/System/Library/Frameworks/Foundation.framework/Headers/NSEnumerator.h:40:38: error:
expected a type
@interface NSEnumerator<ObjectType> (NSExtendedEnumerator)
^
/System/Library/Frameworks/Foundation.framework/Headers/NSEnumerator.h:42:1: error:
expected selector for Objective-C method
@property (readonly, copy) NSArray<ObjectType> *allObjects;
^
/System/Library/Frameworks/Foundation.framework/Headers/NSEnumerator.h:42:28: error:
unknown type name 'NSArray'
@property (readonly, copy) NSArray<ObjectType> *allObjects;
^
/System/Library/Frameworks/Foundation.framework/Headers/NSEnumerator.h:42:35: error:
expected member name or ';' after declaration specifiers
@property (readonly, copy) NSArray<ObjectType> *allObjects;
~~~~~~~^
/System/Library/Frameworks/Foundation.framework/Headers/NSEnumerator.h:42:1: error:
property requires fields to be named
@property (readonly, copy) NSArray<ObjectType> *allObjects;
^ ~~~~~~~
/System/Library/Frameworks/Foundation.framework/Headers/NSEnumerator.h:42:35: error:
expected ';' at end of declaration list
@property (readonly, copy) NSArray<ObjectType> *allObjects;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_qtkit.mm.o] Error 1
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
make: *** [all] Error 2
Any ideas on what happened?
I re-installed Xcode and I can make
and make install
opencv3 again.
Sorry to post this here, bu I am really looking for fast solution, and found the MATLAB support package almost working with no errors. So, I am wondering if someone can help with the MATLAB opencv support package. That package works fine, and I can mex
my c++ codes. However, there is this particular function imdecode()
that produces the following error in MATLAB:
Error using mexOpenCV (line 120)
Undefined symbols for architecture
x86_64:
"cv::imdecode(cv::_InputArray const&,
int)", referenced from:
_mexFunction in decodeUDPimg.o
ld: symbol(s) not found for architecture
x86_64
clang: error: linker command failed with
exit code 1 (use -v to see invocation)
Any ideas on what could be the problem
Thanks for the support. I switched to the Mathworks support package for opencv, as the installation is straightforward. I wished to use this powerful tool, but the installation process, I guess, need to improve a bit.
Thanks.
Hi, I just ran into this problem with the incompatible libtiff
and I managed to make it work with clues from #110. The following fixed it for me:
cd /Applications/MATLAB_R2016a.app/bin/maci64
mkdir libs.bak
mv libtiff.5.dylib libs.bak/
ln -s /usr/local/opt/libtiff/lib/libtiff.5.dylib
For me it was the libtiff
provided by MATLAB that was causing the problem.
> Error using cv.calcHist
Invalid MEX-file '/Users/solosuper/src/mexopencv/+cv/calcHist.mexmaci64': dlopen(/Users/solosuper/src/mexopencv/+cv/calcHist.mexmaci64, 6): Library
not loaded: /usr/local/opt/libtiff/lib/libtiff.5.dylib
Referenced from: /usr/local/opt/opencv3/lib/libopencv_imgcodecs.3.1.dylib
Reason: Incompatible library version: libopencv_imgcodecs.3.1.dylib requires version 8.0.0 or later, but libtiff.5.dylib provides version 6.0.0
$ otool -L /Applications/MATLAB_R2016a.app/bin/maci64/libtiff.5.dylib
/Applications/MATLAB_R2016a.app/bin/maci64/libtiff.5.dylib:
@rpath/libtiff.5.dylib (compatibility version 6.0.0, current version 6.5.0)
(...)
while
$ otool -L /usr/local/opt/libtiff/lib/libtiff.5.dylib
/usr/local/opt/libtiff/lib/libtiff.5.dylib:
/usr/local/opt/libtiff/lib/libtiff.5.dylib (compatibility version 8.0.0, current version 8.4.0)
(...)
After moving the library to a backup directory and symlinking the newer one in stead, the problem is gone.
PS. I also tried DYLD_INSERT_LIBRARIES=/usr/local/lib/libtiff.5.dylib /Applications/MATLAB_R2016a.app/bin/matlab
, but that didn't help.
@solosuper thanks, this finally got my installation working.
@solosuper I'm having this exact same problem, however im new to homebrew so could you please tell me how to symlink the newer libraries?
@lasuomela It's been a long time since I looked at this, so for all I know things might have changed.
Anyways, the first snippet of code i posted (4 lines) did the trick for me. Everything below the line is just to describe why it worked.
I'm not on a Mac right now so I can't test, but you should be able to install libtiff
with homebrew like so: brew install libtiff
.
That command installed the required file at /usr/local/opt/libtiff/lib/libtiff.5.dylib
.
What my 4 lines did was to move the MATLAB-provided library out of the way (to a directory I named libs.bak
), and the line
ln -s /usr/local/opt/libtiff/lib/libtiff.5.dylib
did the so called symlinking. That means to link the homebrew-file into the current directory, which is /Applications/MATLAB_R2016a.app/bin/maci64
(from the first line).
Again, this post is from august last year, so things like libtiff
version might have changed (I can't check for myself right now). But the installed library will hopefully still be installed to usr/local/opt/libtiff/lib
.
I confirm that @solosuper's commands just worked for me. If this works for a third person, maybe it should be documented in the README.md
.
@kubark42, @solosuper, @lasuomela
It is somewhat explained in the troubleshooting section in the wiki, although we proposed a different solution by preloading the conflicting libraries (using DYLD_INSERT_LIBRARIES
) instead of replacing MATLAB's libs with symlinks.
So in this case you would launch MATLAB as:
DYLD_INSERT_LIBRARIES=/usr/local/opt/libtiff/lib/libtiff.5.dylib /Applications/MATLAB_R2016a.app/bin/matlab
No need to overwrite any files.
I'm not on a Mac, so can't test it myself. But I think it should work. If not, I can add the symlink approach as an alternative in the wiki... Can someone confirm please?
@amroamroamro I don't have Matlab on Mac anymore, but it seems true that DYLD_INSERT_LIBRARIES
trick does not work in recent Macs. According to the following post, adding DYLD_FORCE_FLAT_NAMESPACE=1
might be a workaround.
http://stackoverflow.com/questions/34114587/dyld-library-path-dyld-insert-libraries-not-working
@kyamagu
interesting, thanks for the link.
In addition to having to worry about two-level namespace executables, apparently there's also the question of whether the matlab binary is code-signed with some restrictions. From what I understood, OS X (El Capitan and above?) would then ignore all DYLD_*
variables (as a security measure against possible code injections).. You can see how this works in dyld source code (look for the processRestricted
and pruneEnvironmentVariables
functions).
I edited the wiki page to mention the symlink method.
@amroamroamro Thanks for the follow-up and Wiki edits. Yep, there seems no good workaround at this moment.
The libtiff5 which loaded by matlab is from e.g. OS path = '/Applications/MATLAB_R2016a.app/bin/maci64/' (my case) and this libtiff5 in matlab OS path is version 6.0.0. So all you need to do is delete the libtiff5 or rename it as 'libtiff.5.dylib.bak.' , and create a softlink from ln from homebrew installed libtiff to matlab OS path.
e.g. in my case is
ln -s /usr/local/Cellar/libtiff/4.0.7_2/lib/libtiff.5.dylib /Applications/MATLAB_R2016a.app/bin/maci64/libtiff.5.dylib
I had the same problem and the solution by @solosuper worked for me.
I mean that one:
cd /Applications/MATLAB_R2016a.app/bin/maci64
mkdir libs.bak
mv libtiff.5.dylib libs.bak/
ln -s /usr/local/opt/libtiff/lib/libtiff.5.dylib
This is documented in the wiki under:
https://github.com/kyamagu/mexopencv/wiki/Troubleshooting-(UNIX)#macos
It mentions the preload method first, then symlinking as alternative.