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

3 次查看(过去 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