# Question on using the GMT wrapper

**URL:** <https://discourse.julialang.org/t/question-on-using-the-gmt-wrapper/28968>\
**Category:** New to Julia\
**Tags:** gmt\
**Created:** [September 19, 2019, 8:38pm UTC](https://discourse.julialang.org/t/question-on-using-the-gmt-wrapper/28968 "2019-09-19T20:38:47Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![natgeo-wong](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/natgeo-wong/32/10965_2.png) [@natgeo-wong](https://discourse.julialang.org/u/natgeo-wong)\
**Post date:** [September 19, 2019, 8:38pm UTC](https://discourse.julialang.org/t/question-on-using-the-gmt-wrapper/28968/1 "2019-09-19T20:38:47Z")

</div>

Hi all,

I have a macOS, running Julia on Juno. I am trying to install the GMT wrapper into Julia, and it seems to work at a glance. However, when I run GMT, I get the following error:

ERROR: error compiling finish\_PS\_module: error compiling gmt: could not load library “libgmt”  
dlopen(libgmt.dylib, 1): image not found

I have installed GMT6 using the application, and GMT6 runs fine on Terminal. Might I know what the issue here is though? I tried to define libgmt.dylib, and got another error in that I was unable to define the variable.

Cheers!

---

<div class="post-metadata">

**Author:** ![alejandromerchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alejandromerchan/32/10500_2.png) [@alejandromerchan](https://discourse.julialang.org/u/alejandromerchan)\
**Post date:** [September 19, 2019, 8:45pm UTC](https://discourse.julialang.org/t/question-on-using-the-gmt-wrapper/28968/2 "2019-09-19T20:45:27Z")

</div>

Have you tried going into the package manager shell and doing `] build GMT`? Sometimes you need to do that for the package to connect with those external libraries. I’ve run GMT from Julia in the past, but haven’t done in a while.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [September 19, 2019, 8:47pm UTC](https://discourse.julialang.org/t/question-on-using-the-gmt-wrapper/28968/3 "2019-09-19T20:47:32Z")

</div>

Quoting from: [GitHub - GenericMappingTools/GMT.jl at 94f8b13f7beabcc4f198166f45bb3bcd7eedbba8](https://github.com/GenericMappingTools/GMT.jl/tree/94f8b13f7beabcc4f198166f45bb3bcd7eedbba8#install) (emphasise _not_ mine)

> [@](#):
>
> The _GMT.jl_ Julia wrapper does **NOT** install the [GMT](https://github.com/GenericMappingTools/gmt) program. It’s the user responsability to do that.

`]build GMT` would do nothing, there is no `deps/build.jl` file.

---

<div class="post-metadata">

**Author:** ![alejandromerchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alejandromerchan/32/10500_2.png) [@alejandromerchan](https://discourse.julialang.org/u/alejandromerchan)\
**Post date:** [September 19, 2019, 8:48pm UTC](https://discourse.julialang.org/t/question-on-using-the-gmt-wrapper/28968/4 "2019-09-19T20:48:49Z")

</div>

Ok, good to know. Then it’s something related to paths, probably?

---

<div class="post-metadata">

**Author:** ![natgeo-wong](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/natgeo-wong/32/10965_2.png) [@natgeo-wong](https://discourse.julialang.org/u/natgeo-wong)\
**Post date:** [September 19, 2019, 8:54pm UTC](https://discourse.julialang.org/t/question-on-using-the-gmt-wrapper/28968/5 "2019-09-19T20:54:28Z")

</div>

I think it’s something to do with the libgmt paths, but I’m not sure how to do in and change it.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [September 19, 2019, 9:49pm UTC](https://discourse.julialang.org/t/question-on-using-the-gmt-wrapper/28968/6 "2019-09-19T21:49:49Z")

</div>

Hi,  
Unfortunately we have this mystery on OSX that is tackled in [this issue](https://github.com/GenericMappingTools/GMT.jl/issues/298#issuecomment-533303528). Basically if user installs GMT using, for instances, homebrew then all goes well. However, if user uses our [GMT bundle](https://github.com/GenericMappingTools/gmt/releases/download/6.0.0rc4/gmt-6.0.0rc4-darwin-x86_64.dmg), which works perfectly well on bash shell, then incomprehensible dependency conflicts come up. That is what @natgeo-wong is facing. I want also to emphasize that this dependency conflict with the bundle does not restrict to the Julia wrapper. We also face a similar situation with the Matlab and PyGMT interfaces. And that is all in OSX. Other OS do not suffer from it.

Any help from people with knowledge of the OSX linking mechanism that can help us on this will be most well come.

---

<div class="post-metadata">

**Author:** ![natgeo-wong](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/natgeo-wong/32/10965_2.png) [@natgeo-wong](https://discourse.julialang.org/u/natgeo-wong)\
**Post date:** [September 19, 2019, 11:54pm UTC](https://discourse.julialang.org/t/question-on-using-the-gmt-wrapper/28968/7 "2019-09-19T23:54:18Z")

</div>

Thank you very much! I will download the GMT from homebrew instead!

---

<div class="post-metadata">

**Author:** ![natgeo-wong](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/natgeo-wong/32/10965_2.png) [@natgeo-wong](https://discourse.julialang.org/u/natgeo-wong)\
**Post date:** [September 20, 2019, 12:38am UTC](https://discourse.julialang.org/t/question-on-using-the-gmt-wrapper/28968/8 "2019-09-20T00:38:48Z")

</div>

Hi! I installed using Brew, however I’m getting the following error:

ERROR: ccall: could not find function gmt\_manage\_workflow in library libgmt  
Stacktrace:  
[1] gmt\_manage\_workflow at /Users/natgeo-wong/.julia/packages/GMT/Ba3R6/src/libgmt.jl:389 [inlined]  
[2] gmt(::String) at /Users/natgeo-wong/.julia/packages/GMT/Ba3R6/src/gmt\_main.jl:138  
[3] finish\_PS\_module(::Dict{Symbol,Any}, ::String, ::String, ::String, ::String, ::String, ::Bool, ::Bool, ::Bool) at /Users/natgeo-wong/.julia/packages/GMT/Ba3R6/src/common\_options.jl:2189  
[4] #coast#193(::Nothing, ::Bool, ::Base.Iterators.Pairs{Symbol,Any,NTuple{8,Symbol},NamedTuple{(:region, :proj, :frame, :area, :land, :water, :figsize, :show),Tuple{Symbol,Symbol,Symbol,Int64,Symbol,Symbol,Int64,Bool}}}, ::typeof(coast), ::String) at /Users/natgeo-wong/.julia/packages/GMT/Ba3R6/src/pscoast.jl:147  
[5] (::getfield(GMT, Symbol(“#kw##coast”)))(::NamedTuple{(:region, :proj, :frame, :area, :land, :water, :figsize, :show),Tuple{Symbol,Symbol,Symbol,Int64,Symbol,Symbol,Int64,Bool}}, ::typeof(coast)) at ./none:0  
[6] top-level scope at none:0

I am currently using GMT5 because the brew version does not support GMT6 installation. Is this an issue due to this version discrepancy?

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [September 20, 2019, 10:08am UTC](https://discourse.julialang.org/t/question-on-using-the-gmt-wrapper/28968/9 "2019-09-20T10:08:37Z")

</div>

Yes, although I intend to make the wrapper work with GMT5 as well I’ve not tested for a while (the development is all done with GMT6). And yes, since GMT6.0 is not yet officially out (only the RC4) homebrew does not have a formula yet but you can use this one (shown in the issue that pointed above)

```julia
brew install https://raw.githubusercontent.com/claudiodsf/homebrew-core/GMT6.0.0/Formula/gmt.rb

```

---

<div class="post-metadata">

**Author:** ![natgeo-wong](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/natgeo-wong/32/10965_2.png) [@natgeo-wong](https://discourse.julialang.org/u/natgeo-wong)\
**Post date:** [September 20, 2019, 2:10pm UTC](https://discourse.julialang.org/t/question-on-using-the-gmt-wrapper/28968/10 "2019-09-20T14:10:53Z")

</div>

Thank you, I will attempt to use this later!

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [September 20, 2019, 4:11pm UTC](https://discourse.julialang.org/t/question-on-using-the-gmt-wrapper/28968/11 "2019-09-20T16:11:41Z")

</div>

And I’ll try to make work again with GMT5

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [September 21, 2019, 4:28pm UTC](https://discourse.julialang.org/t/question-on-using-the-gmt-wrapper/28968/12 "2019-09-21T16:28:17Z")

</div>

But it does work with GMT5. The error you got came from [this line](https://github.com/GenericMappingTools/GMT.jl/blob/master/src/gmt_main.jl#L137), which is only executed if `GMTver == 6` and that variable is set in the `GMT.jl` at [this line](https://github.com/GenericMappingTools/GMT.jl/blob/master/src/GMT.jl#L11) by inquiring the system what GMT version you have installed. I don’t see how it can get a value `6.0` if you only ever had GMT5.

What I just found and it’s not so nice is that after GMT.jl gets pre-compiled then even if you update the GMT version, the info about the version in the wrapper is not updated unless one forces recompiling `GMT.jl`

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [September 21, 2019, 5:47pm UTC](https://discourse.julialang.org/t/question-on-using-the-gmt-wrapper/28968/13 "2019-09-21T17:47:11Z")

</div>

I think maybe those constants should be set in ` __init__ ()` so they don’t get precompiled ([docs](https://docs.julialang.org/en/v1/manual/modules/index.html#Module-initialization-and-precompilation-1)).

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [September 21, 2019, 6:35pm UTC](https://discourse.julialang.org/t/question-on-using-the-gmt-wrapper/28968/14 "2019-09-21T18:35:26Z")

</div>

Thanks, you are probably right but I then fall into other problems because I need to know the value of the `GMTver`` at compile time in other included files. The issue is that several C structs in GMT have different contents on the two versions (5 or 6) and I need to know which one to ccal and apparently that is decided at compile time and not at runtime.

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [September 22, 2019, 12:50pm UTC](https://discourse.julialang.org/t/question-on-using-the-gmt-wrapper/28968/15 "2019-09-22T12:50:00Z")

</div>

Ah ok. Maybe it can be done at build time (`build/build.jl` writes a file `deps/constants.jl` that has the values hardcoded and is included by the package). That way the user can call `Pkg.build(“GMT”)` to reset the constants.

I’m not really sure if that’s actually better than the current system though.

---

<div class="post-metadata">

**Author:** ![natgeo-wong](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/natgeo-wong/32/10965_2.png) [@natgeo-wong](https://discourse.julialang.org/u/natgeo-wong)\
**Post date:** [September 22, 2019, 3:01pm UTC](https://discourse.julialang.org/t/question-on-using-the-gmt-wrapper/28968/16 "2019-09-22T15:01:37Z")

</div>

Hmmmmm alright, I’ll try that again! Thanks for the head’s up, yeah because I installed GMTv6 first before moving over to GMTv5 when it didn’t work.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [September 22, 2019, 4:12pm UTC](https://discourse.julialang.org/t/question-on-using-the-gmt-wrapper/28968/17 "2019-09-22T16:12:45Z")

</div>

But if you have GMT6, by all means use it instead of GMT5, The issue is that you need to force a GMT.jl precompile when you change your GMT version. A dirty way is to just change something irrelevant in GMT.jl and next time you do `using GMT` it will be _re-precompiled_.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [September 22, 2019, 8:07pm UTC](https://discourse.julialang.org/t/question-on-using-the-gmt-wrapper/28968/18 "2019-09-22T20:07:57Z")

</div>

I made a commit to master that warns users when they are caught in that situation of GMT.jl being out of phase with the installed GMT version.

---

<div class="post-metadata">

**Author:** ![natgeo-wong](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/natgeo-wong/32/10965_2.png) [@natgeo-wong](https://discourse.julialang.org/u/natgeo-wong)\
**Post date:** [September 22, 2019, 10:16pm UTC](https://discourse.julialang.org/t/question-on-using-the-gmt-wrapper/28968/19 "2019-09-22T22:16:02Z")

</div>

Mmmmmm I need to reinstall GMT6 using homebrew because it doesn’t work when I download the GMT6.app, which was the initial problem.

Thank you all so much for your time and your help!
