Segmentation Fault or "undefined symbol" error when using MATLAB Engine with RHEL or CentOS Linux
6 views (last 30 days)
Show older comments
MathWorks Support Team
on 3 Jun 2021
Edited: MathWorks Support Team
on 28 Jun 2024
When I run this simple script using MATLAB Engine for Python on RHEL (or Centos) Linux, I get a Segmentation Fault. Sometimes, instead of a Segmentation fault, I get the following type of error: "libstdc++.so.6: undefined symbol: __cxa_thread_atexit_impl". These issues occur on the "import matlab.engine()" command.
import matlab.engine
eng=matlab.engine.start_matlab()
eng.sqrt(4.)
How can I fix these issues when using MATLAB Engine with RHEL 7 (or Centos 7) Linux?
Accepted Answer
MathWorks Support Team
on 28 Jun 2024
There can be an incompatibility of the C runtime for MATLAB Engine on some RedHat and CentOS Linux operating systems. If that is the case, forcing Python Engine to load the shim library will fix the issue. Follow the steps below to preload the shim library.
On the Linux machine:
Find the path to the MATLAB root folder. This path can be displayed by typing the following command in the MATLAB Command Window.
>> matlabroot
Substitute this path for matlabroot in the commands below.
In a Linux terminal, determine the name of the shim library
ls matlabroot/bin/glnxa64/glibc-*
Determine the name of the shim library
ls matlabroot/bin/glnxa64/glibc-*
Determine which type of terminal is being used.
echo $0
For a csh/tcsh terminal, execute the following command (this example assumes 2.17 version of the shim library)
setenv LD_PRELOAD matlabroot/bin/glnxa64/glibc-2.17_shim.so
For a bash terminal, execute the following command.
export LD_PRELOAD=matlabroot/bin/glnxa64/glibc-2.17_shim.so
Run the Python code in the same terminal.
0 Comments
More Answers (0)
See Also
Categories
Find more on Call MATLAB from Python in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!