Why does a LD_PRELOAD error appear when using MEX commands on Linux?

73 views (last 30 days)
I am working on Linux (Red Hat 7.8)  and am experiencing errors while trying to run mex commands.
Below is the error log when setting up MEX compiler:
>> mex -setup
Segmentation fault (core dumped)
ERROR: ld.so: object '/raid/tools/MATLAB/R2021a/bin/glnxa64/glibc-2.17_shim.so' from LD_PRELOAD cannot be preloaded: ignored.
Segmentation fault (core dumped)
ERROR: ld.so: object '/raid/tools/MATLAB/R2021a/bin/glnxa64/glibc-2.17_shim.so' from LD_PRELOAD cannot be preloaded: ignored.
Segmentation fault (core dumped)
ERROR: ld.so: object '/raid/tools/MATLAB/R2021a/bin/glnxa64/glibc-2.17_shim.so' from LD_PRELOAD cannot be preloaded: ignored.
Segmentation fault (core dumped)
ERROR: ld.so: object '/raid/tools/MATLAB/R2021a/bin/glnxa64/glibc-2.17_shim.so' from LD_PRELOAD cannot be preloaded: ignored.
Segmentation fault (core dumped)
ERROR: ld.so: object '/raid/tools/MATLAB/R2021a/bin/glnxa64/glibc-2.17_shim.so' from LD_PRELOAD cannot be preloaded: ignored.
Segmentation fault (core dumped)
ERROR: ld.so: object '/raid/tools/MATLAB/R2021a/bin/glnxa64/glibc-2.17_shim.so' from LD_PRELOAD cannot be preloaded: ignored.
MEX configured to use 'gcc' for C language compilation.
Output for echo LD_PRELOAD in terminal:
LD_PRELOAD: Undefined variable.
Executing MCC command to compile a simple library:
>> mex -v -DMEX -outdir C_model/mex C_model/source/mex/encode_C.cpp C_model/source/Accessories.cpp C_model/source/Channel.cpp C_model/source/CoDec.cpp C_model/source/Encoder.cpp C_model/source/GF2.cpp C_model/source/Index.cpp
Verbose mode is on.
... Looking for compiler 'g++' ...
... Executing command 'which g++' ...Segmentation fault (core dumped)
ERROR: ld.so: object '/raid/tools/MATLAB/R2021a/bin/glnxa64/glibc-2.17_shim.so' from LD_PRELOAD cannot be preloaded: ignored.
Yes ('/home/liork/.local/bin/g++').
... Executing command 'g++ -print-file-name=libstdc++.so' ...Segmentation fault (core dumped)
ERROR: ld.so: object '/raid/tools/MATLAB/R2021a/bin/glnxa64/glibc-2.17_shim.so' from LD_PRELOAD cannot be preloaded: ignored.
Yes ('/usr/local/gcc/9.2.0/lib64/libstdc++.so').
... Executing command 'g++ -dumpversion' ...Segmentation fault (core dumped)
ERROR: ld.so: object '/raid/tools/MATLAB/R2021a/bin/glnxa64/glibc-2.17_shim.so' from LD_PRELOAD cannot be preloaded: ignored.
Yes ('9.2.0').
... Executing command 'which g++' ...Segmentation fault (core dumped)
ERROR: ld.so: object '/raid/tools/MATLAB/R2021a/bin/glnxa64/glibc-2.17_shim.so' from LD_PRELOAD cannot be preloaded: ignored.
Yes ('/home/liork/.local/bin/g++').
... Looking for folder '/usr/local/gcc/9.2.0' ...Yes.
... Executing command 'g++ -dumpmachine' ...Segmentation fault (core dumped)
ERROR: ld.so: object '/raid/tools/MATLAB/R2021a/bin/glnxa64/glibc-2.17_shim.so' from LD_PRELOAD cannot be preloaded: ignored.
Yes ('x86_64-pc-linux-gnu').
Found installed compiler 'g++'.
... Looking for compiler 'g++' ...
... Executing command 'which g++' ...Segmentation fault (core dumped)
I have everything installed correctly, including MATLAB and C compiler (GCC). I have also tried to set LY_PRELOAD using "setenv()", but the issue persists.
What can be the cause of the issue?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 3 Dec 2021
When the OS has C Shell as default, you may run into this issue.
To overcome this issue, we need to invoke MATLAB under bash. One of the ways to do this is create a "startup.m" file that sets MATLAB to use bash. You can use the following document to create or edit this file:
After you have opened the "startup.m" in MATLAB, please add the following line and save:
setenv SHELL /bin/bash
It will have MATLAB invoke bash automatically without impacting the rest of your system. Restart MATLAB after this file is changed and saved, and test if this resolves the issue.

More Answers (0)

Categories

Find more on Get Started with MATLAB Compiler SDK in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!