Info

この質問は閉じられています。 編集または回答するには再度開いてください。

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

1 回表示 (過去 30 日間)
Quan
Quan 2015 年 9 月 29 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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.

回答 (1 件)

Walter Roberson
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.

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by