This question is closed. Reopen it to edit or answer.
C/MATLAB API interface settings affects other applications in OS X
2 views (last 30 days)
Show older comments
Quan on 29 Sep 2015
Closed: MATLAB Answer Bot on 20 Aug 2021
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:
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.
Walter Roberson on 30 Sep 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.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!