Can MATLAB use prototype files to load shared C library if that library has dependencies?

조회 수: 2 (최근 30일)
I'm trying to use MATLAB's loadlibrary function to load a shared library that has dependencies on a Linux RHEL8 workstation using a prototype file.
>> loadlibrary(library_path,@libfuncprototype)
Error using loadlibrary
There was an error loading the libary
"/opt/Lib64/libfunc.so"
libsubfunc.so.5: cannot open shared object file: No such file or directory
Caused by:
Error using loaddefinedlibrary
libsubfunc.so.5: cannot open shared object file: No such file or directory
Both libfunc.so and libsubfunc.so.5 (not their real names but sufficient for explaining the issue) exist in /opt/Lib64. When I run:
system(ldd('/opt/Lib64/libfunc.so')
the return shows that dependent library libsubfunc.so.5 was found
I investigated setting LIB_LIBRARY_PATH and LIB_RUN_PATH prior to the loadlibrary command, but I still get the same result when running loadlibary.
Questions:
  • Can MATLAB load shared libraries using prototype file if the libraries have dependencies?
  • How do I tell MATLAB to search in the same directory as the library for dependencies?
  댓글 수: 2
Toni
Toni 2022년 4월 25일
I used setenv within MATLAB to set LD_LIBRARY_PATH and confirmed it was set using getenv. However, when I used loadlib, I saw no difference, I still got the same error message.

댓글을 달려면 로그인하십시오.

답변 (1개)

Toni
Toni 2022년 4월 29일
With the LD_LIBRARY_PATH defined in the environment before starting up MATLAB, loadlibary is able to load libaries with dependencies.
As I previously noted, using setenv within MATLAB to define LD_LIBRARY_PATH has no effect. The loadlibrary function fails to find the dependent libaries in this case.

카테고리

Help CenterFile Exchange에서 Application Deployment에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by