MATLAB: How To Set LD_LIBRARY_PATH on Linux for Deployed Code without MCR

code compilerMATLABmccmcrr2020b

I have a ulitily requiring MATLAB R2020b features which I want to deploy. The system (a managed linux environment) has MATLAB R2020b installed but currently not the MCR. I'm looking for an interim solution to deploy the code before R2020b's MCR is available. I feel I should be able to point the launch script at the MATLAB R2020b installation to gain access to the libraries.
How can I adapt the launch script to use libraries from MATLAB?
I have tried pointing MCRROOT to the MATLAB R2020b installation folder (which has worked in previous releases). All the subdirectories referenced by the script exist — but I get the following error.
myDeployedCode: symbol lookup error: /opt/localsoft/cdtng/tools/matlab/R2020b/sys/os/glnxa64/libstdc++.so.6: undefined symbol: __cxa_thread_atexit_impl
I don't have rights to change either the system settings or the MATLAB installation, so I need to work with the current setup.
So, I have two questions:
  1. Is what I'm trying to do even possible?
  2. What should my launch script look like to correctly pick up all the required libraries?
Any suggestions much appreciated.

Best Answer

I have found the answer. Using RedHad Enterprise Server 7 linux distribution and for R2020b compiled code, a specific patch is required.
The launch shell script generated by the MCC includes the change, but as I was using a custom launch script, the patch was not picked up. The error was catsed by the missing patch. Adding the line from the MCC-generated script solves the issue.
The line is:
# Preload glibc_shim in case of RHEL7 variants
test -e /usr/bin/ldd && ldd --version | grep -q "(GNU libc) 2\.17" \
&& export LD_PRELOAD="${MCRROOT}/bin/glnxa64/glibc-2.17_shim.so"
If you use the automatically generated launch script, then the change for R2020b is automatically handled for you.