Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

C/MATLAB API interface settings affects other applications in OS X

1 visualizzazione (ultimi 30 giorni)
I'm calling MATLAB from my c++ code via the MATLAB Engine API library on a Mac. I learned that I need to set the environment variable:
export PATH='/Applications/MATLAB_R2015a.app/bin:$PATH'
export DYLD_LIBRARY_PATH='/Applications/MATLAB_R2015a.app/bin/maci64:/Applications/MATLAB_R2015a.app/sys/os/maci64:$DYLD_LIBRARY_PATH'
then I was able to setup the Matlab engine running. However I realised the setting of those environment variables have other effects: within the shell, curl stops working. What's worse is that some multi-threaded codes compiled by openmp stop working as well. I hope to learn an alternative way of setting the environment for Matlab API, without disrupting other applications.

Risposte (1)

Walter Roberson
Walter Roberson il 30 Set 2015
In POSIX (and OS-X is POSIX certified), you can fork a process, set the environment variables in the process, and exec a new executable, which will have the modified environment variables. This is the procedure that is used by the shell itself.
Once you have a MATLAB process, if you have code called from it that needs different libraries, then you can setenv() within MATLAB before calling upon those routines with system(), or you can have the string you system() be one that sets the environment variables as needed for what you are calling upon.

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by