Overriding DYLD library... any problems?

10 views (last 30 days)
Kelly Kearney
Kelly Kearney on 29 Jul 2013
Does anyone know if I will break anything important in Matlab (R2013a on Mac OS X 10.8.4) if I override the DYLD_LIBRARY_PATH and DYLD_FRAMEWORK_PATH environmental variables?
I'm encountering some issues attempting to access netcdf functions via direct system calls. For example
>> system('ncgen -o test.nc test.cdl')
dyld: Library not loaded: /opt/local/lib/libnetcdf.7.dylib
Referenced from: /opt/local/bin/ncdump
Reason: Incompatible library version: ncdump requires version 10.0.0 or later, but libnetcdf.7.dylib provides version 9.0.0
ncdump test.nc: Trace/breakpoint trap
ans =
133
Running the same ncgen command from a terminal prompt works fine. Looking at the environmental variables both within and without Matlab, it looks like Matlab is explicitly setting the DYLD_FRAMEWORK_PATH and DYLD_LIBRARY_PATH variables:
>> getenv('DYLD_FRAMEWORK_PATH')
ans =
/Applications/MATLAB_R2013a.app/sys/os/maci64:/Applications/MATLAB_R2013a.app/bin/maci64/../../Contents/MacOS:/Applications/MATLAB_R2013a.app/bin/maci64:/Applications/MATLAB_R2013a.app/extern/lib/maci64:/Applications/MATLAB_R2013a.app/runtime/maci64
to reference a version that conflicts with my installed version of the netcdf libraries. I can fix my problem if I just reset these two variables, i.e. setenv('DYLD_LIBRARYPATH',''), allowing the system call to find the correct version of the dyld libraries. But I'm curious if I'm going to end up breaking anything important by doing so.

Answers (1)

Ken Atwell
Ken Atwell on 10 Aug 2013
Edited: Ken Atwell on 10 Aug 2013
I imagine things will be just fine if you:
  1. Cache a copy of results of getenv
  2. setenv as you described
  3. Call the system command
  4. Restore the environment variable to the value you cached.
Maybe wrap all of that up in a little help function.

Community Treasure Hunt

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

Start Hunting!