Segmentation Fault or "undefined symbol" error when using MATLAB Engine with RHEL or CentOS Linux
조회 수: 6 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2021년 6월 3일
편집: MathWorks Support Team
2024년 6월 28일
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?
채택된 답변
MathWorks Support Team
2024년 6월 28일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Call MATLAB from Python에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!