System commands requiring libraries (non-matlab related) do not work when executed from a standalone app.
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jairo Andrés Gutiérrez Suárez
el 23 de Mzo. de 2022
Comentada: Image Analyst
el 30 de Mzo. de 2022
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.
0 comentarios
Respuestas (1)
Image Analyst
el 23 de Mzo. de 2022
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 comentarios
Walter Roberson
el 30 de Mzo. de 2022
If you only need to write to the terminal without reading back then see https://www.mathworks.com/matlabcentral/fileexchange/13851-popen-read-and-write
Image Analyst
el 30 de Mzo. de 2022
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.
Ver también
Categorías
Más información sobre Get Started with MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!