Info
此问题已关闭。 请重新打开它进行编辑或回答。
C/MATLAB API interface settings affects other applications in OS X
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Walter Roberson
2015-9-30
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.
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!