dyld: Library not loaded in automatically generated shell script.

조회 수: 7 (최근 30일)
John Knowles
John Knowles 2020년 6월 22일
댓글: Esther 2025년 8월 4일
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.
  댓글 수: 2
Goldie Song
Goldie Song 2024년 1월 11일
any response/support from MathWorks?
Esther
Esther 2025년 8월 3일
I have an almost identical problem. MathWorks?

댓글을 달려면 로그인하십시오.

답변 (1개)

John Knowles
John Knowles 2025년 8월 3일
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
  댓글 수: 1
Esther
Esther 2025년 8월 4일
Thank you for your response. However, I am in fact using Matlab Compiler.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by