Hello all,
I’m having an unusual problem with the Matlab interface. Calling Simulator.create() returns an empty sim object. I am running some simple Lumped Rate Models. The strange thing is that they ran perfectly until recently, with no changes to the core package, so I assume no changes to the MexSimulator(). Any advice?
Thanks,
Andy
Hi Andy,
if you are getting an empty object/array from Simulator.create()
, Matlab could not load the mex binary.
Please run MexSimulator()
in the Matlab command window. This should print some error messages.
If you have recompiled CADET, also consider the situation of this thread: Mac OS Installation
Hi Sam,
I have not recompiled, but yes it is not finding the binary for no reason I can understand. The error is as it was on the original compilation (below), but I have confirmed that the libtbb_preview.dylib is correct and in place.
Andy
Error:
Invalid MEX-file
‘/Users/Andy/Dropbox/RadTran/Models/Chromatography
models/Advection Diffusion
model/CADET/cadet/matlab/bin/CadetMex.mexmaci64’:
dlopen(/Users/Andy/Dropbox/RadTran/Models/Chromatography
models/Advection Diffusion
model/CADET/cadet/matlab/bin/CadetMex.mexmaci64, 6): Library not
loaded: @rpath/libtbb_preview.dylib
Referenced from:
/Users/Andy/Dropbox/RadTran/Models/Chromatography
models/Advection Diffusion
model/CADET/cadet/matlab/bin/CadetMex.mexmaci64
Reason: image not found
Error in MexSimulator (line 137)
obj.mexHandle = CadetMex(‘create’);
This seems strange, indeed. Let’s find out what the rpath
of the CadetMex.mexmaci64
dynamic library is:
Please run this in the terminal in the folder of the CadetMex.mexmaci64
file and post the results:
otool -l CadetMex.mexmaci64 | grep RPATH -A10
Ah, this looks like the answer. I moved the entire folder into a dropbox location for sharing. A path correction should fix it. Unfortunately I’m not sure how to do that.
Many thanks,
Andy
cmd LC_RPATH
cmdsize 48
path /Users/Andy/Desktop/CADET/cadet/lib (offset 12)
Load command 19
cmd LC_RPATH
cmdsize 56
path /Applications/MATLAB_R2019a.app/bin/maci64 (offset 12)
Load command 20
cmd LC_RPATH
cmdsize 64
path /Applications/MATLAB_R2019a.app/extern/bin/maci64 (offset 12)
Load command 21
cmd LC_RPATH
cmdsize 72
path /Users/Andy/Desktop/CADET/Libs/tbb-2020.3-mac/tbb/lib (offset 12)
Load command 22
cmd LC_RPATH
cmdsize 32
path @executable_path/. (offset 12)
I think, I was wrong in the other post. The correct rpath
should probably be @loader_path
instead of @executable_path
. Please add the @loader_path
to CadetMex.mexmaci64
:
install_name_tool -add_rpath @loader_path/. CadetMex.mexmaci64
The @executable_path
points to the directory that contains the running binary (i.e., /Applications/MATLAB_R2019a.app/bin/maci64/
). But we need the path relative to the directory of the .dylib
(i.e., relative to the directory of CadetMex.mexmaci64
itself), which is given by @loader_path
.
If this works, you should be able to move the folder around without having to change the files. I’ll also update the other post if this fixes the problem.