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 Center および File ExchangeMATLAB Compiler についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by