# GMT Julia and ubuntu v18

**URL:** <https://forum.generic-mapping-tools.org/t/gmt-julia-and-ubuntu-v18/1270>\
**Category:** GMT.jl Q&A\
**Created:** [January 26, 2021, 8:46pm UTC](https://forum.generic-mapping-tools.org/t/gmt-julia-and-ubuntu-v18/1270 "2021-01-26T20:46:05Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![charper](https://avatars.discourse-cdn.com/v4/letter/c/96bed5/32.png) [@charper](https://forum.generic-mapping-tools.org/u/charper)\
**Post date:** [January 26, 2021, 8:46pm UTC](https://forum.generic-mapping-tools.org/t/gmt-julia-and-ubuntu-v18/1270/1 "2021-01-26T20:46:06Z")

</div>

I am aware that installing GMT with Julia only adds the wrapper. I have downloaded GMT and followed the directions from its git repository: [https://github.com/GenericMappingTools/gmt/blob/master/INSTALL.md](https://github.com/GenericMappingTools/gmt/blob/master/INSTALL.md).

GMT is installed and runs fine from my terminal. However whenever I try to use GMT in Julia I get the following message:

```auto
    You don't seem to have GMT installed and I don't install it automatically,
    so you will have to do it yourself.
    https://github.com/GenericMappingTools/gmt/blob/master/INSTALL.md#linux

```

This is a common problem where the solution is to show julia where my gmt library is. I did this by adding the following lines to my startup.jl:

```auto
    using Libdl
    push!(Libdl.DL_LOAD_PATH, "/usr/lib/x86_64-linux-gnu/libgmt.so.5")
    push!(Libdl.DL_LOAD_PATH, "/usr/lib/x86_64-linux-gnu/libgmt.so.5.4.3")

```

I added both paths because I was not sure which one was the correct library (running gmt --version says its version 5.4.3)

However, when I load GMT I get the same message as before. Furthermore when I do `] test GMT`  
I get the following error:

```auto
    You don't seem to have GMT installed and I don't install it automatically,
    so you will have to do it yourself.
    https://github.com/GenericMappingTools/gmt/blob/master/INSTALL.md#linux
    5.4.3
    ERROR: LoadError: UndefVarError: GMT_Get_Version not defined
    Stacktrace:
     [1] getproperty(::Module, ::Symbol) at ./Base.jl:26
     [2] top-level scope at /home/charper/.julia/packages/GMT/3tQ7w/test/runtests.jl:17
     [3] include(::String) at ./client.jl:439
     [4] top-level scope at none:6
    in expression starting at /home/charper/.julia/packages/GMT/3tQ7w/test/runtests.jl:12
    ERROR: Package GMT errored during testing

```

Here are the first 20 ish lines of runtest.jl

```auto
    using GMT
    using Test
    
    try
    	run(`gmt --version`)	# Will fail if GMT is not installed.
    	global got_it = true
    catch
    	@test 1 == 1 # Let tests pass for sake of not triggering a PkgEval failure
    	global got_it = false
    end
    
    if (got_it) # Otherwise go straight to end
    
    	const dbg2 = 3 # Either 2 or 3. 3 to test the used kwargs
    	const dbg0 = 0 # With 0 prints only the non-consumed options. Set to -1 to ignore this Vd
    
    	GMT.GMT_Get_Version();
    	ma=[0];mi=[0];pa=[0];
    	GMT.GMT_Get_Version(ma,mi,pa);
    	API = GMT.GMT_Create_Session("GMT", 2, GMT.GMT_SESSION_NOEXIT + GMT.GMT_SESSION_EXTERNAL);
    	GMT.GMT_Get_Ctrl(API);

```

Not sure what to do next, any help is appreciated!

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [January 26, 2021, 10:33pm UTC](https://forum.generic-mapping-tools.org/t/gmt-julia-and-ubuntu-v18/1270/2 "2021-01-26T22:33:48Z")

</div>

Hello @charper, I’m sorry that linux is making your life harder than it needs. But let’s start over. You should not need to set any `LOAD_PATH`, GMT.jl finds the GMT shared lib via system’s path. If running GMT from command line works, so should the GMT wrapper do. What does it print when you run in Julia REPL?

```auto
readlines(`gmt --version`)[1]

```

and I hope that this “libgmt.so.5.4.3” does not mean GMT5. The GMT wrapper, since version 0.23, only works with GMT6 (when it works, a message informing this is issued).

```auto

```

---

<div class="post-metadata">

**Author:** ![charper](https://avatars.discourse-cdn.com/v4/letter/c/96bed5/32.png) [@charper](https://forum.generic-mapping-tools.org/u/charper)\
**Post date:** [January 26, 2021, 11:18pm UTC](https://forum.generic-mapping-tools.org/t/gmt-julia-and-ubuntu-v18/1270/3 "2021-01-26T23:18:44Z")

</div>

Hi Joaquim. Thanks for the reply! The Julia REPL returned a string with the version number “5.4.3”:

```auto
julia> readlines(`gmt --version`)[1]
"5.4.3"

julia>

```

Following the Ubuntu instructions here ([https://github.com/GenericMappingTools/gmt/blob/master/INSTALL.md#linux](https://github.com/GenericMappingTools/gmt/blob/master/INSTALL.md#linux)) I installed GMT and its dependencies by running the following commands:

```auto
sudo apt-get install gmt gmt-dcw gmt-gshhg
# required
sudo apt-get install ghostscript
# optional
sudo apt-get install gdal-bin graphicsmagick ffmpeg

```

It does mention that the Debian/Ubuntu official repositories might be slightly out of date…perhaps they are so out of date as to be running version 5? They do provide instructions for building from the source for the most up-to-date versions ([https://github.com/GenericMappingTools/gmt/blob/master/BUILDING.md](https://github.com/GenericMappingTools/gmt/blob/master/BUILDING.md)). This looked much more complicated, so I stuck to the standard install directions. At the time I thought that not being completely up-to-date was fine, but if you think the Ubuntu18.04 repositories are using a deprecated version, I can try to build from the source. However, if there are simpler things I could try first, that would be great. Although, I guess I should learn to build from the source eventually haha…

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [January 26, 2021, 11:59pm UTC](https://forum.generic-mapping-tools.org/t/gmt-julia-and-ubuntu-v18/1270/4 "2021-01-26T23:59:06Z")

</div>

Hmm, I still don’t get it why you got errors instead of the warning that GMT6 is needed. But shit, even the _10-years-old-versions-are-more-stable-Ubuntu_ should have GMT6. I’m almost sure that I already installed GMT6 from packages in Ubuntu. @seisman you know more?

Anyway, GMT6 is indeed needed. Building from source is not so complicated as the (extensive) docs pages may indicate. It’s just a matter of installing the dependencies first and then the `Cmake` step.

---

<div class="post-metadata">

**Author:** ![charper](https://avatars.discourse-cdn.com/v4/letter/c/96bed5/32.png) [@charper](https://forum.generic-mapping-tools.org/u/charper)\
**Post date:** [January 27, 2021, 2:23am UTC](https://forum.generic-mapping-tools.org/t/gmt-julia-and-ubuntu-v18/1270/5 "2021-01-27T02:23:29Z")

</div>

Ok so I went ahead and built from source. It was not as bad as I thought it would be! Now when I run `gmt --version` in terminal 6.1.1, is returned. However, I am still having the same issue with Julia. Could it be the install paths? my gmt is isntalled in usr/local/lib/ while I think julia might be installed in usr/home/…but if I include those explicit lines to the gmt path, should it matter?

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [January 27, 2021, 2:29am UTC](https://forum.generic-mapping-tools.org/t/gmt-julia-and-ubuntu-v18/1270/6 "2021-01-27T02:29:44Z")

</div>

> [@charper](#):
>
> ```auto
> using Libdl
> push!(Libdl.DL_LOAD_PATH, "/usr/lib/x86_64-linux-gnu/libgmt.so.5")
> push!(Libdl.DL_LOAD_PATH, "/usr/lib/x86_64-linux-gnu/libgmt.so.5.4.3")
> 
> ```

Do you still have this?  
Install path is irrelevant. Better to get rid of GMT5, you may be having issues with mixed versions.

---

<div class="post-metadata">

**Author:** ![charper](https://avatars.discourse-cdn.com/v4/letter/c/96bed5/32.png) [@charper](https://forum.generic-mapping-tools.org/u/charper)\
**Post date:** [January 27, 2021, 3:13am UTC](https://forum.generic-mapping-tools.org/t/gmt-julia-and-ubuntu-v18/1270/7 "2021-01-27T03:13:32Z")

</div>

Good idea! I removed those lines from my startup.jl, unfortunately nothing changed.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [January 27, 2021, 3:31am UTC](https://forum.generic-mapping-tools.org/t/gmt-julia-and-ubuntu-v18/1270/8 "2021-01-27T03:31:50Z")

</div>

> [@Joaquim](#):
>
> `readlines(`gmt --version`)[1]`

Again, what does it says now?

```auto
readlines(`gmt --version`)[1]

```

Must be some remainings of previous settings/installation.

---

<div class="post-metadata">

**Author:** ![charper](https://avatars.discourse-cdn.com/v4/letter/c/96bed5/32.png) [@charper](https://forum.generic-mapping-tools.org/u/charper)\
**Post date:** [January 27, 2021, 4:17am UTC](https://forum.generic-mapping-tools.org/t/gmt-julia-and-ubuntu-v18/1270/9 "2021-01-27T04:17:51Z")

</div>

It returns the string “6.1.1” . Do you think the issue is with the fact that I have julia installed at `/home/charper/` and I have GMT installed at `/usr/local/lib`?

---

<div class="post-metadata">

**Author:** ![seisman](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/seisman/32/4_2.png) [@seisman](https://forum.generic-mapping-tools.org/u/seisman)\
**Post date:** [January 27, 2021, 4:34am UTC](https://forum.generic-mapping-tools.org/t/gmt-julia-and-ubuntu-v18/1270/10 "2021-01-27T04:34:55Z")

</div>

> [@Joaquim](#):
>
> Hmm, I still don’t get it why you got errors instead of the warning that GMT6 is needed. But shit, even the _10-years-old-versions-are-more-stable-Ubuntu_ should have GMT6. I’m almost sure that I already installed GMT6 from packages in Ubuntu. @seisman you know more?

Here are the GMT versions that Ubuntu provide:

- Ubuntu 18.04 =\> GMT 5.4.3
- Ubuntu 20.04 =\> GMT 6.0.0
- Ubuntu 20.10 =\> GMT 6.1.0

---

<div class="post-metadata">

**Author:** ![charper](https://avatars.discourse-cdn.com/v4/letter/c/96bed5/32.png) [@charper](https://forum.generic-mapping-tools.org/u/charper)\
**Post date:** [January 27, 2021, 4:46am UTC](https://forum.generic-mapping-tools.org/t/gmt-julia-and-ubuntu-v18/1270/11 "2021-01-27T04:46:27Z")

</div>

Thanks seisman! I managed to get GMT6.1.1 running on 18.04 by doing a build from the source material.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [January 27, 2021, 2:45pm UTC](https://forum.generic-mapping-tools.org/t/gmt-julia-and-ubuntu-v18/1270/12 "2021-01-27T14:45:25Z")

</div>

Hmm, what might be happening is this. In your first attempt it pre-compiled GMT.jl and now, since nothing has changed in the code to trigger another pre-compilation Julia is using the faulty one. Go to `/home/charper/.juliacompiled/v1.5/GMT` and delete the file(s) there.

---

<div class="post-metadata">

**Author:** ![charper](https://avatars.discourse-cdn.com/v4/letter/c/96bed5/32.png) [@charper](https://forum.generic-mapping-tools.org/u/charper)\
**Post date:** [January 27, 2021, 7:53pm UTC](https://forum.generic-mapping-tools.org/t/gmt-julia-and-ubuntu-v18/1270/13 "2021-01-27T19:53:33Z")

</div>

That worked. Thank you so much! In summary, using the ubuntu 18 repositories defaults to version 5, which I guess was causing the problem. Upgrading to version 6 by installing from the source, and then forcing Julia to do another pre-compilation fixed everything.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [January 27, 2021, 11:35pm UTC](https://forum.generic-mapping-tools.org/t/gmt-julia-and-ubuntu-v18/1270/14 "2021-01-27T23:35:01Z")

</div>

Good that you finally got it to work. It should have shown you this warning. But the problem is if one only update GMT and not GMT.jl the old precompiled version will keep saying the same though that’s no longer true.

```auto
julia> cd("c:/v"); @time using GMT
[Info: Precompiling GMT [5752ebe1-31b9-557e-87aa-f909b540aa54]

        GMT version 5 is no longer supported (support ended at 0.23).
 18.142623 seconds (2.03 M allocations: 125.454 MiB, 0.23% gc time, 1.63% compilation time)

```
