dyld: Library not loaded in automatically generated shell script.

7 Ansichten (letzte 30 Tage)
John Knowles
John Knowles am 22 Jun. 2020
Kommentiert: Esther am 4 Aug. 2025
My problem is the "dyld: Library not loaded:" error that has been discussed several times in this forum. However the proposed solutions do not work for me. I wonder if its because MacOS has changed. The shell file seems to get the path right, and the file libmwlaunchermain.dylib is present in the target folder (/Applications/MATLAB/MATLAB_Runtime/v98/bin/maci64). So this does not seem to be the previously disccused error of not getting the path to the MCR correct. I also tried without the MCR, just using the installed Matlab (export MCR_ROOT=/Applications/MATLAB_R2020a.app) but this gave the same result.
In terminal, I run ./run_MainCalib.sh $MCR_ROOT SolverInputs.mat
This generates
Setting up environment variables
---
MCRROOT is /Applications/MATLAB/MATLAB_Runtime/v98
DYLD_LIBRARY_PATH is ./Applications/MATLAB/MATLAB_Runtime/v98/runtime/maci64:/Applications/MATLAB/MATLAB_Runtime/v98/bin/maci64:/Applications/MATLAB/MATLAB_Runtime/v98/sys/os/maci64
dyld: Library not loaded: @rpath/libmwmclmcrrt.9.8.dylib
Referenced from: /Applications/MATLAB/MATLAB_Runtime/v98/bin/maci64/libmwlaunchermain.dylib
Reason: image not found
./run_MainCalib.sh: line 30: 88488 Abort trap: 6 "./MainCalib.app/Contents/MacOS/MainCalib" "SolverInputs.mat"
I read https://www.mathworks.com/matlabcentral/answers/473971-how-do-i-configure-the-ld_library_path-on-linux-and-dyld_library_path-on-mac-os-x-to-point-to-mcr, which seems to suggest the problem is that MacOS has changed the way environment variables propagate within nested shells, but the solution proposed there does not apply directly to running a standalone from a shell file, as the shell script creates the DYLD_LIBRARY_PATH and the shell script is automatically generated by matlab.

Antworten (1)

John Knowles
John Knowles am 3 Aug. 2025
If I recall correctly, the solution was to give up trying to compile in Terminal and instead use the compile facilities from within the Matlab prompt. I have been away from this project for a few years, so I cannot remember the details. Here is the code from the .m file I wrote around that time to compile from within Matlab,
%MacMexFile.m
%creates SS_Solve
%define macro variables;
startdir = pwd; %remember where we were
HomeDir = getenv('HOME') ;
CompVar = computer;
if strcmp(CompVar,'MACI64'), %mac
NRfolder = [HomeDir '/Dropbox/Libraries/clibs/NumRec/NR3Code']; %I prefer not to create extra copies of the NR code
ProgDir = [HomeDir '/Dropbox/Papers/EducMatch']; %where the code is stashed
else %linux
ProgDir = [HomeDir '/EducMatch']; %where the code is stashed
NRfolder = ProgDir; %where the numerical recipe .h files are stored
end
CPPDir = [ProgDir '/CPPCode'];
CPPstr = 'SS_Solve.cpp EquilObjects.cpp Erf_JK.cpp StaticConditions.cpp SteadyStateStruct.cpp';
Product = [ProgDir '/Matlab/SolveMatch/SS_Solve'];
cmdstr=['mex ' CPPstr ' -I' CPPDir ' -I' ProgDir ' -I' NRfolder ' -output ' Product];
addpath(genpath('ProgDir')) %put all the .m files on the path;
eval(['cd ' CPPDir]) %so that matlab knows where these files are
eval(cmdstr) %main event: compile the mex file
eval(['cd ' startdir]) %return us to initial folder

Kategorien

Mehr zu MATLAB Compiler finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by