Does the GMT.jl package conflict with the MAT.jl and NCDatasets.jl packages?

I have a very weird situation.

I can plot a map using my GMT.jl package. I can also load my NetCDF data using NCDatasets.jl without any issues. However, if I first use NCDatasets.jl to load the data in and then use GMT.jl to plot in the same program, using GMT will give me the below error.

According to the error message, the reason seems to be “Incompatible library version: libgdal.29.dylib requires version 202.0.0 or later, but libhdf5.200.dylib provides version 201.0.0”.

**ERROR:** LoadError: InitError: could not load library "/Users/xxx/.julia/conda/3/lib/libgdal.29.dylib"

dlopen(/Users/xxx/.julia/conda/3/lib/libgdal.29.dylib, 1): Library not loaded: @rpath/libhdf5.200.dylib

Referenced from: /Users/xxx/.julia/conda/3/lib/libgdal.29.dylib

Reason: Incompatible library version: libgdal.29.dylib requires version 202.0.0 or later, but libhdf5.200.dylib provides version 201.0.0

Stacktrace:

[1] **GDALVersionInfo(** a1::String **)**

@ GMT.Gdal ~/.julia/packages/GMT/TPV4a/src/gdal.jl:317

[2] **__init__()**

@ GMT.Gdal ~/.julia/packages/GMT/TPV4a/src/gdal.jl:2403

[3] **_include_from_serialized(** path::String, depmods::Vector{Any} **)**

@ Base ./loading.jl:768

[4] **_require_search_from_serialized(** pkg::Base.PkgId, sourcepath::String **)**

@ Base ./loading.jl:854

[5] **_require(** pkg::Base.PkgId **)**

@ Base ./loading.jl:1097

[6] **require(** uuidkey::Base.PkgId **)**

@ Base ./loading.jl:1013

[7] **require(** into::Module, mod::Symbol **)**

@ Base ./loading.jl:997

during initialization of module Gdal

in expression starting at /Users/xxx/Desktop/Julia_CODAP/Plotting_GMT.jl:20

(base) MacBook-Pro Julia_CODAP %

Anyone has seen that issue before? I’m using Julia on Mac OS Big Sur, BTW. Many thanks.

I tried to convert the gridded data from NetCDF to MAT file so that I could avoid the use of the NCDatasets package. However, the MAT package caused the same error.

Can you try loading in the inverse order?

using GMT
using NCDatasets

I don’t have an explanation but I used to have a similar problem with JLD, it may be related because all three use the HDF5 library.

2 Likes

Thank you so much! It works :+1: :+1:

I’m trying to find the relevant github issue, but It would be nice if you could open one at NCDatasets and GMT, just in case some else finds it. I seem to remember it was a problem in the HDF5 library, not sure.

OK. Will do.

What can I say. That is unix and its normal dependencies conflicts. I have this NCDatasets.jl fork that uses the GDAL, netCDF, (train of shared libs) provided by GMT and should protect from those lib conflicts.

1 Like

Cool. Is that fork easy to setup? Any details to share?

Sorry, that one from a package of 4 and it’s the only one that has no install instructions (and the fork is ~ 1 year old). To install, first remove your current NCDatasets and then do

] add https://github.com/joa-quim/NCDatasets.jl

Note, all of this is reversible. If not satisfied remove this and re-install the official one.

1 Like

I am wondering why we have this library conflict. Does GMT.jl use its own hdf5/NetCDF library (or system libraries) rather than using Julia’s NetCDF_jll? If yes, would building GMT on Yggdrasil not be the better solution?

Many thanks, Joa-quim!

Unfortunately, I got the below error:

**julia>** ] add https://github.com/joa-quim/NCDatasets.jl
**ERROR:** syntax: unexpected "]"

So I tried to use Pkg.add(url="") to install it. It seems to be installed successfully, but when I run my program, the using NCDatasets syntax gives me a page-long error that started as the below:

**ERROR:** LoadError: This package can only be installed in systems that have GMT

That’s strange, because I do have the GMT package, and I’m able to use it to make plots.

Does GMT.jl use its own hdf5/NetCDF library (or system libraries) rather than using Julia’s NetCDF_jll?

GMT.jl no, but the GMT C lib yes.

I would love to, but two big stones in the way

  • Yggdarsil/ BinaryBuilder doesn’t work from Windows
  • GDAL_jll is not build with netCDF and HDF support. This is a killing feature to GMT.

I am wondering if alternatively, you could use the Preferences module to override the location of HDF5/NetCDF4 and to point to the libraries of the GMT package.
For example:

Would this achieve the same as your fork of NCDatasets?
I had similar problem in the past with zlib (pre-BinaryBuild which solved such problems for me). I used the LD_PRELOAD trick (mbedtls issue in Fedora linux · Issue #126 · Alexander-Barth/NCDatasets.jl · GitHub) to pre-load the right library (you can pre-load multiple libraries if they are separated by a space . But LD_PRELOAD might be Unix (or Linux) specific.

I will try to give another look at this but basically this fork was for my own usage where, on Windows, there is no risk of conflicts with netCDF artifact dlls.