I have installed a linux version of fico xpress, which uses mosel as its binary executable. I can call mosel from any directory and execute a .mos model (along with argument passing) as follows:mosel -c exec PATH/TO/MODEL arg1='value1', arg2='value2'which finishes with exit code 0.However, when I place the same text as above in a run.sh file and:sh run.shI get:dyld: Library not loaded: libxprm_mc.dylibReferenced from: /usr/local/opt/xpress/bin/moselReason: image not foundrun.sh: line 4: 22768 Trace/BPT trap: 5       mosel -c exec PATH/TO/MODEL arg1='value1', arg2='value2'I have searched for the dylib file, and it does not exist (as far as I can tell).EDIT: I found the dylib file in /usr/local/opt/xpress/lib  Also of note, in order to run mosel from the command line I also had to set the following in /etc/launchd.conf:setenv XPRESSDIR /usr/local/opt/xpresssetenv PATH $XPRESSDIR/bin:$PATHsetenv LD_LIBRARY_PATH $XPRESSDIR/lib:$LD_LIBRARY_PATHsetenv CLASSPATH $XPRESSDIR/lib/xprs.jar:$CLASSPATH setenv CLASSPATH $XPRESSDIR/lib/xprb.jar:$CLASSPATH setenv CLASSPATH $XPRESSDIR/lib/xprm.jar:$XLASSPATH setenv XPRESS $XPRESSDIR/binWhy am I getting this error from a shell script, but not from executing the same line in the terminal?
Why does my mac terminal command NOT work in a shell script?
linux;osx;shell
In your script try exporting the DYLD_LIBRARY_PATH environment variable with the dylib path:export DYLD_LIBRARY_PATH=/usr/local/opt/xpress/bin/lib:${DYLD_LIBRARY_PATH}mosel -c exec PATH/TO/MODEL arg1='value1', arg2='value2'This should let the mosel executable know where the dynamic library is located.