dyld: Library not loaded in automatically generated shell script.

8 vues (au cours des 30 derniers jours)
John Knowles
John Knowles le 22 Juin 2020
Commenté : Esther le 4 Août 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.
  2 commentaires
Goldie Song
Goldie Song le 11 Jan 2024
any response/support from MathWorks?
Esther
Esther le 3 Août 2025
I have an almost identical problem. MathWorks?

Connectez-vous pour commenter.

Réponses (1)

John Knowles
John Knowles le 3 Août 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
  1 commentaire
Esther
Esther le 4 Août 2025
Thank you for your response. However, I am in fact using Matlab Compiler.

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB Compiler dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by