Setting LD_LIBRARY_PATH for MatlabEngine java call
Mostrar comentarios más antiguos
I am developing a maven mojo plugin to compile my MATLAB code used in a Tomcat servlet. It just grabs a few paths from maven, assembles a call to mcc, and passes that to an instance of MatlabEngine. The problem is that unless I define LD_LIBRARY_PATH (either in .bashrc, or by sourcing my own script), LD_LIBRARY_PATH is empty and the program dies in the call:
Future<MatlabEngine> eng = MatlabEngine.startMatlabAsync();
I assumed .matlab7rc.sh would be invoked, but watching the file access:
$ sudo auditctl -l
-w /usr/local/MATLAB/R2020a/bin/.matlab7rc.sh -p rx -k matlab7rc
shows the program isn't accessing that file. Even strace:
strace -o strace.out -f -t -e trace=file mvn install
grep matlab7rc strace.out
shows no access. I understand I can define LD_LIBRARY_PATH in a shell script, but this seems inelegant. I haven't found a clean way to define an environment variable within the pom.xml, and while I could use java.util ProcessBuilder to define the environment, this is a long run for a short slide. Suggestions?
3 comentarios
Jeff Mandel
el 25 de Dic. de 2020
Fredrik Qwarfort
el 30 de Dic. de 2020
Editada: Fredrik Qwarfort
el 30 de Dic. de 2020
I had the same annoying errors. Try to add the /usr/local/MATLAB/R2020a/sys/os/glnxa64 to your LD_LIBRARY_PATH.
export LD_LIBRARY_PATH=/usr/local/MATLAB/R2020a/bin/glnxa64:/usr/local/MATLAB/R2020a/sys/os/glnxa64:$LD_LIBRARY_PATH
The gcc compiler libraries used by Matlab is located there and it uses those libraries instead of the ones installed in your system, which probably is not the same versions.
Jeff Mandel
el 30 de Dic. de 2020
Respuestas (0)
Categorías
Más información sobre Get Started with MATLAB Compiler SDK en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!