MATLAB 2014a (8.3) Compiler Runtime Errors libmwlaunchermain.so - matlab

MATLAB 2014a (8.3) Runtime Compiler (MCR) Errors when trying to launch deployed (using
deploy tool) application in Ubuntu 13.04.
Right after installation of MCR if one runs the deployed application following error appears:
error while loading shared libraries: libmwlaunchermain.so: cannot open shared object file: No such file or directory.

Since I have already found a solution to this problem wasting a day, I just want to share it:
This seems to be a problem of MATLAB MCR installation script designed for Linux by MathWorks. Furthermore, it is a result of a known Ubuntu bug. To fix it, add your MCR to the $PATH as shown below:
First make sure to add the missing files to the right folder, in terminal:
sudo cp /usr/local/MATLAB/MATLAB_Compiler_Runtime/v83/runtime/glnxa64/* /usr/local/MATLAB/MATLAB_Compiler_Runtime/v83/bin/glnxa64
Add the proper library folder to your .profile, such that this change will stay after logout
ubuntu: gedit .profile
In the end of the file add following lines:
#MATLAB MCR
export LD_LIBRARY_PATH=/usr/local/MATLAB/MATLAB_Compiler_Runtime/v83/bin/glnxa64
export XAPPLRESDIR=/usr/local/MATLAB/MATLAB_Compiler_Runtime/v83/X11/app-defaults
export PATH=$PATH:$LD_LIBRARY_PATH
export PATH=$PATH:$XAPPLRESDIR
Invoke following code in the terminal to make sure that Ubuntu bug doesn't re-write your variable:
echo STARTUP=\"/usr/bin/env LD_LIBRARY_PATH=\${LD_LIBRARY_PATH} \${STARTUP}\" | sudo tee /etc/X11/Xsession.d/90preserve_ld_library_path
Reboot
If this solution doesn't work, try to reinstall MATLAB MCR 8.3 from the MathWorks website and repeat the steps.

In my case (Matlab R2016b = v91), the binary generated by Matlab was accompanied by a shell script which sets up the LD_LIBRARY_PATH for me. If I just run
./run_scriptname.sh
it complains about the missing <deployedMCRroot>. So running the script with
./run_scriptname.sh /home/user/MatlabMCR/v91
it worked out of the box.
For me, it was not obvious that the path shown above is the <deployedMCRroot> because I chose /home/user/MatlabMCR as installation directory. And with the wrong path specified, it led to the same error message.

Related

libhdf5.so.103: cannot open shared object file

I have met a problem with hdf5 libraries on eclipse CDT. When running a test C++ program, I got prompt information as below:
/home/lsl/Documents/CODE/eclipse-workspace/ReadWriteHDF5/Debug/ReadWriteHDF5:
error while loading shared libraries: libhdf5.so.103: cannot open
shared object file: No such file or directory.
libhdf5.so is confirmed to exist in /usr/local/lib/hdf5-1.10.4/lib and /usr/local/lib/hdf5-1.10.4/lib is within LD_LIBRARY_PATH. Do you have any indications?
Thanks very much!
It looks like Linux is your main operating system. See what happens when you type
sudo apt install libhdf5-dev
since it might supplant the package you're looking for. It worked for me.
I come across similar issue while compiling C++ code that uses Armadillo. Since I have anaconda installed, I find the libhdf5.so.103 file located at ~/anaconda3/lib. After I add the path to LD_LIBRARY_PATH, the error disappears.
I came across exactly the same problem today (perhaps the only difference is that it complaint libhdf5.so.200 was missing). What I eventually found out is that the system (Ubuntu 20.04) already shipped with libhdf5-dev at version 1.10.4, and this conflicted somehow with my installed version 1.12.2. My build command line is as below:
clang++ <...> -L/my/custom/path/to/hdf5-1.12.2/hdf5/lib <...>
Since the system hdf5 is in standard location, the linker finds simultaneously two versions, causing problem.
My solution is:
sudo apt purge libhdf5-dev
Hope it helps.

Using Matlab runtime on Mac and Linux

I am trying to use MCR to run an executable file that I created using
mcc -mv mycode.m
I installed MCR (2017a Matlab) for Mac from here https://uk.mathworks.com/products/compiler/matlab-runtime.html. After this, I edited the .bashrc file to set the path as instructed at the end of installation by:
export DYLD_LIBRARY_PATH=/Applications/MATLAB/MATLAB_Runtime/v92/runtime/maci64:/Applications/MATLAB/MATLAB_Runtime/v92/sys/os/maci64:/Applications/MATLAB/MATLAB_Runtime/v92/bin/maci64
After the above I typed in terminal to run the executable file as:
sh mycode.sh
But this gives the following message
Usage: mycode.sh deployedMCRroot args
Can anyone help me with what I may be missing here?
I am right now installing MCR on the same machine on which I used MATLAB to
generate executable file. I am doing this to test the output file.
deployedMCRroot refers to the directory in which you installed the MCR. Supposing that your script doesn't require any additional argument, if you installed MCR under /Applications/MCR/, you should type the following command in order to make your script work:
sh mycode.sh /Applications/MCR/
Normally, at installation time, the MCR framework is installed in the chosen directory but placed into a subfolder describing its version. So it's possible that you may be required the correct MCR framework specifying the proper version as follows:
sh mycode.sh /Applications/MCR/v70/

library error after compiling

Using 2012b on Centos6 I compiled my code using deploytool.
To be sure I'm doing things correctly, I re-install the MCR to make sure I'm using the exact version matlab wants me to use. Following the instructions after installing the MCR (v83) I append the corresponding paths to LD_LIBRARY_PATH and XAPPLRESDIR.
When I use the run_myProgram.sh script. It echos out the library paths and I can see that the MCR paths are correct.
However, at the startup of my compiled program, I'm getting this error:
"error while loading shared libraries: libmwmclmcrrt.so.8.0: cannot open shared object file: No such file or directory"
Anyone out there have a way to fix this? For example, is it a problem with my system configuration or a problem with my deployment?
The plot thickens. I noticed that in the MCR installation, I only have libmwmclmcrrt.so.8.3. How does the deploytool not give me the version I need?
thanks!
You need to download MCR version 8.0 for r2012b. Please see the table here : MCR Version Table

Running Matlab MCR and MATLAB on the Same Machine

I'm having trouble getting a compiled .exe file to run with MCR instead of Matlab (I can tell because the program is using multiple threads, which it would not do if it were running with MCR). The MATLAB documentation (http://www.mathworks.com/help/toolbox/compiler/f12-999353.html) says:
"To run deployed components against the MCR install, mcr_root\ver\runtime\win32|win64 must appear on your system path before matlabroot\runtime\win32|win64.
If mcr_root\ver\runtime\arch appears first on the compiled application path, the application uses the files in the MCR install area.
If matlabroot\runtime\arch appears first on the compiled application path, the application uses the files in the MATLAB Compiler installation area."
Can anyone connect the dots a bit more for me? I don't know what this means. Thanks!
I had the same problem: my compiled code was multithreaded, which I did not want.
The problem got solved by compiling with the option:
-R -singleCompThread
You need to set properly the PATH global environment variable in Windows. How you do it exactly depends on Windows version.
Here is the first link from Google by query "set path on Windows": http://www.computerhope.com/issues/ch000549.htm
This variable is a list of directories. Make sure you have a directory with MCR executable earlier in this list than a directory with MATLAB executable.

Runtime error for MCC compiled program using parfor

I have problems running a program compiled with MCC that uses parfor. The non-compiled .m version works (no bug). When I run the compiled version, I get
"distcomp.remoteparfor" is undefined. I believe I exactly have the error described in
the following link.
http://www.mathworks.com/support/solutions/en/data/1-PAHWE/index.html?product=CO&solution=1-PAHWE
However, since MCR is not installed on my machine (got Matlab and MCC),
I am wondering what the pathes $APPNAME_mcr/java/jar/toolbox and
$MCR/MATLAB Component Runtime/v70/java/jar/toolbox correspond to. I found
the distcomp.jar file in C:\Program Files\MATLAB\R2011b\java\jar\toolbox, but I don't know where to put it since see any path corresponding to $MCR/MATLAB Component Runtime/v70/java/jar/toolbox since MCR is not installed.
Thanks a lot!
Fred
No need to install the MCR if you are simply trying to run the application on the same machine that has MATLAB. The question to ask is, HOW are you launching the compiled application? From a DOS command window? From within MATLAB using the SYSTEM command?
If you are launching the application from a DOS / UNIX command line, then the important thing to keep in mind is that the MATLAB binaries need to be on your system path i.e. just make sure:
$MATLABROOT\bin\$ARCH
is on your system path. Where $MATLABROOT is the matlab installation folder, and $ARCH is your system architecture. For example:
c:\work\matlab\bin\win64
on my machine since my installation folder which contains MATLAB is:
c:\work
and i am on a win64 machine.
The problem is solved. The solution is to make the program
a function instead of a script :
http://www.mathworks.com/matlabcentral/answers/22825-parfor-errors-when-file-is-compiled