-1

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 find an alternative way of setting the environment for Matlab API, without disrupting other applications. Thanks.

yu quan
  • 161
  • 1
  • 1
  • 14

1 Answers1

1

I found a few solutions here. Linking to a dynamic library on a Mac with full path

In particular I like quazgar's answer the best. When a program looking for a library path in DYLD_LIBRARY_PATH fails to find the needed library, the program will look into the environment variable DYLD_FALLBACK_LIBRARY_PATH if there is such a variable.

The solution is to change DYLD_FALLBACK_LIBRARY_PATH instead of DYLD_LIBRARY_PATH. Change of DYLD_LIBRARY_PATH is not recommended in any circumstances, as it will creates lots of trouble for the environment.

Community
  • 1
  • 1
yu quan
  • 161
  • 1
  • 1
  • 14