System commands requiring libraries (non-matlab related) do not work when executed from a standalone app.

조회 수: 5 (최근 30일)
Dear Forum members.
I am using Matlab R2019a under Ubuntu 18.04 and compiled an standalone app, which is run using the v96 runtime.
The app uses some system commands which call OpenFOAM (c++ software + libraries), which work fine when run from Matlab themselves but do not work under the standalone app.
The error message from the terminal is: "blockMesh: error while loading shared libraries: libblockMesh.so: cannot open shared object file: No such file or directory"
blockMesh is an OpenFOAM executable (which of course runs fine from the terminal itself). When "echo "$LD_LIBRARY_PATH" is run, both OpenFOAM and Matlab libraries are presented:
/usr/lib/openfoam/openfoam2012/platforms/linux64GccDPInt32Opt/lib/sys-openmpi:/usr/lib/x86_64-linux-gnu/openmpi/lib:/home/jairogut/OpenFOAM/jairogut-v2012/platforms/linux64GccDPInt32Opt/lib:/usr/lib/openfoam/openfoam2012/site/2012/platforms/linux64GccDPInt32Opt/lib:/usr/lib/openfoam/openfoam2012/platforms/linux64GccDPInt32Opt/lib:/usr/lib/openfoam/openfoam2012/platforms/linux64GccDPInt32Opt/lib/dummy:/usr/local/MATLAB/MATLAB_Runtime/v96/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v96/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v96/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v96/extern/bin/glnxa64
So I suppose under the standalone app, system commands requiring other libraries cannot be run, right? Is there a workaround for this?
Thank you,
Jairo.

답변 (1개)

Image Analyst
Image Analyst 2022년 3월 23일
Chances are you don't have the full path of the module specified when you try to call it. It's best to specify the full path in your code. What are the lines in your code where you try to use the thing?
Alternatively, but I think less desired, is to include the whole OpenFOAM executable in the CTF with the -a option when you compile.
  댓글 수: 5
Image Analyst
Image Analyst 2022년 3월 30일
Maybe try
fullFileName = fullfile(pwd, 'blockMesh launcher.bat');
% Write a batch file:
fid = fopen(fullFileName, 'wt');
% Change directory to wherever the executable lives.
fprintf(fid, 'cd /usr/lib/openfoam/openfoam2012/platforms/linux64GccDPInt32Opt/lib')
% Tell batch file to launch blockMesh.
fprintf(fid, 'blockMesh')
fclose(fid); % Close the batch file.
% Run the batch file.
system(fullFileName)
Adapt as needed.

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

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by