- Cache a copy of results of getenv
- setenv as you described
- Call the system command
- Restore the environment variable to the value you cached.
Overriding DYLD library... any problems?
11 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Ken Atwell
on 10 Aug 2013
Edited: Ken Atwell
on 10 Aug 2013
I imagine things will be just fine if you:
Maybe wrap all of that up in a little help function.
0 Comments
See Also
Categories
Find more on NetCDF in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!