How can I resolve this mcc runtime error "cannot open shared object library"?

69 views (last 30 days)
What am I doing wrong? I created a standalone executable using mcc. At runtime, I get "error while loading shared libraries: cannot open shared object file: No such file or directory."

Answers (5)

Arnab Sen
Arnab Sen on 26 Feb 2016
Hi Clay, Assuming you are using linux machine, there can be several reasons behind this issue, the primary reason being the incorrect installation of MCR or an incorrect specification of the path to execute the .sh file. In this case, an incorrect path specification was the source of the problem.
Here are some general troubleshooting steps for resolving this issue on Linux:
A. Install a Linux version of the MCR for 2013a from
1. Please ensure that you download a version that matches the bitness of your machine. 2. Extract the files and navigate to the corresponding folder; install MCR by typing “./install” on the command prompt. 3. Make sure you have sufficient privileges to run the setup. Please make note of the directory to which the MCR files are being installed to. 4. If the installation is successful for 2013a, you will see a “v81” folder created in this installation directory.
B. Run the executable with the right path specified.
You can run executable in two ways: . / mcr_installation_dir/v81
Where the environment variable LD_LIBRARY_PATH can be set using the following command:
setenv LD_LIBRARY_PATH mcr_installation_dir /v81/runtime/glnxa64: mcr_installation_dir /v81/bin/glnxa64: mcr_installation_dir /v81/sys/os/glnxa64:
If the above suggestions do not help, then try the following steps: 1. Check if you have a “startup.m” file that is being automatically included in your standalone application. In that case, enclose the commands within “startup.m” under a conditional statement:
If (isdeployed) ; else …original statements go here… end
2. Sometimes the mcrCache is corrupted. Set the "MCR_CACHE_ROOT" environment variable to a directory that you have read and write permissions to.
3.Sometime such error arises if the environment is not setup in UNIX systems. To resolve this issue, set the library path in Linux properly according to the below documentation:

martin claverie
martin claverie on 29 May 2017
I know it is a old post, but I wanted to share how I solved the problem. I got exactly the same issue when I run my compiled code through crontab. Running directly the compiled code on the command line worked good.
the script has been compiled using the deploytool UI. I always use deploytool to compile a code for the first time. Then if I modified the *.m, I use the mcc matlab command line on the packinglog file to re-compile.
So I did that recompiling the code with mcc... and it works ;-) . With deploytool I get the bug, with mcc I don't have it.. No idea why... Cheers

Kevin Ahi
Kevin Ahi on 26 Feb 2018
what is should I change "executable" with the name of my compiled file?

Elizabeth Jolly
Elizabeth Jolly on 24 Feb 2022
Another reason for this can be due to your disk being full.

Thanh on 30 Aug 2023
If Matab executable is submitted to bsub, it could be LD_LIBRARY_PATH and other environment variables are not prograted to bsub job session.


Find more on C Shared Library Integration in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!