External Library version error

2 ビュー (過去 30 日間)
Jonathan Lauderdale
Jonathan Lauderdale 2014 年 3 月 14 日
編集済み: Jonathan Lauderdale 2014 年 3 月 18 日
Hello, I am having some issues with external libraries in Matlab 8.2.0.701 (R2013b) on an iMac OSX 10.9.2 (Mavericks).
I am creating some NetCDF files using the native Matlab interface, which is successful. However, for the last step I use the "system" command to access the NCO (NetCDF Operators) tool "ncatted" to quickly tweak some metadata (add a missing value for all variables) but this fails with the following error:
>> system(['ncatted -O -a missing_value,,c,f,-1.0e34 ',filename])
dyld: Library not loaded: /opt/local/lib/libnetcdf.7.dylib
Referenced from: /opt/local/bin/ncatted
Reason: Incompatible library version: ncatted requires version 10.0.0 or later, but libnetcdf.7.dylib provides version 9.0.0
ncatted -O -a missing_value,,c,f,-1.0e34 psi_data.nc: Trace/breakpoint trap
This is really curious because when I check the versions of the libraries with "ldd" I get:
>> system('ldd /opt/local/bin/ncatted')
/opt/local/bin/ncatted:
/opt/local/lib/libexpat.1.dylib (compatibility version 8.0.0, current version 8.0.0)
/usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
/opt/local/lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.2.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
** /opt/local/lib/libnetcdf.7.dylib (compatibility version 10.0.0, current version 10.0.0)
/opt/local/lib/libcurl.4.dylib (compatibility version 8.0.0, current version 8.0.0)
/opt/local/lib/libgsl.0.dylib (compatibility version 18.0.0, current version 18.0.0)
/opt/local/lib/libgslcblas.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/opt/local/lib/libudunits2.0.dylib (compatibility version 2.0.0, current version 2.0.0)
As you can see, libnetcdf.7.dylib () is indeed version 10.0.0. I also get the same problem with other installed commands, e.g.
>> system(['ncdump -h ',filename])
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 -h psi_data.nc: Trace/breakpoint trap
I originally thought that the problem was with the libraries in $MATLAB_ROOT/bin/maci64 but as the error message shows, it's not these libraries that are inspected...I even tried linking the /opt/local/ libraries into Matlab but that makes things worse!
Is there some sort of path that is confusing Matlab into testing against a version 9 library? Any ideas would be greatly appreciated. Jonathan
  2 件のコメント
Jonathan Lauderdale
Jonathan Lauderdale 2014 年 3 月 14 日
...I should add that these commands work fine when issued straight from the terminal, but they form part of an intermediate processing chain which is why it'd be great if the "system" command performed as expected! J
Jonathan Lauderdale
Jonathan Lauderdale 2014 年 3 月 17 日
編集済み: Jonathan Lauderdale 2014 年 3 月 18 日
I have tried the fix from the unidata netcdf mailing list that suggests setting DYLD_LIBRARY_PATH to /opt/local/lib in my .profile. However, loading Matlab fails completely with a different library issue .

サインインしてコメントする。

採用された回答

Jonathan Lauderdale
Jonathan Lauderdale 2014 年 3 月 18 日
I have found a workaround by altering DYLD_LIBRARY_PATH in my "startup.m" file (placed in ~/Documents/MATLAB):
dylibpath=getenv('DYLD_LIBRARY_PATH');
setenv('DYLD_LIBRARY_PATH',['/opt/local/lib:/usr/local/lib:',dylibpath]);
clear dylibpath
OR in the same file:
setenv('DYLD_LIBRARY_PATH','');
This is only read after Matlab has initialized and so doesn't cause the previous library problems that occur when DYLD_LIBRARY_PATH is set from the terminal. So it seems that Matlab is being a little naughty with setting a restrictive DYLD_LIBRARY_PATH environment, presumably a lazy way to ensure that it's built in libraries are correctly linked to.
I am going to go with the second option and post here any libraries that I find dont work....hopefully they can be tweaked with "install_name_tool". Cheers!
  1 件のコメント
Jonathan Lauderdale
Jonathan Lauderdale 2014 年 3 月 18 日
Okay, so I accidentally left DYLD_LIBRARY_PATH set as in proposed answer (1) and ran into a problem of:
Dyld Error Message:
Symbol not found: __cg_jpeg_resync_to_restart
Referenced from: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO
Expected in: /opt/local/lib/libJPEG.dylib
in /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO
when trying to invoke OSX's "open" command within "system" on an image of a plot that I had just generated.
There is no such problem if DYLD_LIBRARY_PATH is unset as in (2).

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNetCDF についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by