Instructions to install GMT.jl on Ubuntu

Is this the correct way of installing GMT.jl on Ubuntu?
https://github.com/GenericMappingTools/gmt/blob/master/BUILDING.md#build-and-runtime-dependencies

It seems there are a lot of manual steps.

You shouldn’t have to build GMT yourself, rather use the available GMT package from apt:
sudo apt-get install gmt gmt-dcw gmt-gshhg

this is from here:
https://github.com/GenericMappingTools/gmt/blob/master/INSTALL.md#ubuntudebian

And the GMT.jl README says, that it would install it via conda if it is not available in the system.

When you have installed the GMT package you can install the GMT.jl package in Julia via:

pkg>add GMT 
1 Like

Many thanks!

As a newbie to Linux, I’m very glad to hear about this.

Unfortunately, I got the below error, while running Pkg.add(“GMT”):

ERROR: The following 1 direct dependency failed to precompile:
GMT [5752ebe1-31b9-557e-87aa-f909b540aa54]
Failed to precompile GMT [5752ebe1-31b9-557e-87aa-f909b540aa54] to /home/name/.julia/compiled/v1.7/GMT/jl_96Uy7O.
ldd: /usr/lib/x86_64-linux-gnu/libgmt.so: No such file or directory
ERROR: LoadError: failed processes:
Process(ldd /usr/lib/x86_64-linux-gnu/libgmt.so, ProcessExited(1)) [1]
Process(grep libgdal, ProcessExited(1)) [1]

My guess is that you installed from one of those package managers that do not create a symbolic link to the library as is common use on unix and that is why it doesn’t find the libgmt.so

If you run, in a unix shell, gmt --show-bindir it will show you the location of the GMT executable. Then use ldd to find its dependencies. Something like

ldd /usr/bin/gmt | grep libgmt

you will see references to (in my linux box)

libgmt.so.6 => /lib64/libgmt.so.6 (0x00007f45f97ee000)

and

[jluis@fct-gmt lib64]$ ls /usr/lib64/libgmt*
/usr/lib64/libgmt.so  /usr/lib64/libgmt.so.6  /usr/lib64/libgmt.so.6.1.0

The problem in your case (again, my guess) is that your installation lacks the libgmt.so, which is a symbolic link (that should be there). The solution is to create one yourself (in the directory of the shared libs, /usr/lib64/ in this example) do

ln -s libgmt.so libgmt.so.6
1 Like

Many thanks, Joa-quim! Unfortunately, it did not work.

Path to the file: /lib/x86_64-linux-gnu/

$ ln -s libgmt.so libgmt.so.6
ln: failed to create symbolic link ‘libgmt.so.6’: File exists

So it’s the other way around. I never remember the order.

ln -s libgmt.so.6 libgmt.so
2 Likes

Many thanks! I think it did something good. However, when I tried Pkg.add("GMT"), it went through the process really quickly. I got a different error when using GMT.

**ERROR:** InitError: failed process: Process(gmt --show-userdir, ProcessExited(78)) [78]

Below are the details:

(@v1.6) pkg> add GMT
Updating registry at ~/.julia/registries/General
Resolving package versions…
No Changes to ~/.julia/environments/v1.6/Project.toml
No Changes to ~/.julia/environments/v1.6/Manifest.toml

julia> using GMT
[ Info: Precompiling GMT [5752ebe1-31b9-557e-87aa-f909b540aa54]

GMT - The Generic Mapping Tools, Version 6.0.0 [64-bit] [12 cores]
(c) 1991-2019 The GMT Team (https://www.generic-mapping-tools.org/team.html).

Supported in part by the US National Science Foundation (http://www.nsf.gov/)
and volunteers from around the world.

GMT is distributed under the GNU LGP License (http://www.gnu.org/licenses/lgpl.html).

usage: gmt [options]
gmt []

options:
–help List descriptions of available GMT modules.
–new-script[=L] Write GMT modern mode script template to stdout.
Optionally specify bash|csh|batch [Default is current shell]
–show-bindir Show directory with GMT executables.
–show-citation Show the most recent citation for GMT.
–show-cores Show number of available cores.
–show-datadir Show directory/ies with user data.
–show-dataserver Show URL of the remote GMT data server.
–show-doi Show the DOI for the current release.
–show-modules Show all module names.
–show-library Show path of the shared GMT library.
–show-plugindir Show directory for plug-ins.
–show-sharedir Show directory for shared GMT resources.
–version Print GMT version number.

if is ‘=’ we call exit (0) if module exist and non-zero otherwise.

GMT - The Generic Mapping Tools, Version 6.0.0 [64-bit] [12 cores]
(c) 1991-2019 The GMT Team (https://www.generic-mapping-tools.org/team.html).

Supported in part by the US National Science Foundation (http://www.nsf.gov/)
and volunteers from around the world.

GMT is distributed under the GNU LGP License (http://www.gnu.org/licenses/lgpl.html).

usage: gmt [options]
gmt []

options:
–help List descriptions of available GMT modules.
–new-script[=L] Write GMT modern mode script template to stdout.
Optionally specify bash|csh|batch [Default is current shell]
–show-bindir Show directory with GMT executables.
–show-citation Show the most recent citation for GMT.
–show-cores Show number of available cores.
–show-datadir Show directory/ies with user data.
–show-dataserver Show URL of the remote GMT data server.
–show-doi Show the DOI for the current release.
–show-modules Show all module names.
–show-library Show path of the shared GMT library.
–show-plugindir Show directory for plug-ins.
–show-sharedir Show directory for shared GMT resources.
–version Print GMT version number.

if is ‘=’ we call exit (0) if module exist and non-zero otherwise.

ERROR: InitError: failed process: Process(gmt --show-userdir, ProcessExited(78)) [78]

Stacktrace:
[1] pipeline_error
@ ./process.jl:525 [inlined]
[2] (::Base.var"#644#645"{Base.Process})()
@ Base ./process.jl:319
[3] iterate(itr::Base.EachLine{Base.PipeEndpoint}, state::Nothing) (repeats 2 times)
@ Base ./io.jl:1014
[4] _collect(cont::UnitRange{Int64}, itr::Base.EachLine{Base.PipeEndpoint}, #unused#::Base.HasEltype, isz::Base.SizeUnknown)
@ Base ./array.jl:613
[5] collect
@ ./array.jl:602 [inlined]
[6] #readlines#340
@ ./io.jl:551 [inlined]
[7] readlines
@ ./io.jl:551 [inlined]
[8] init(test::Bool)
@ GMT ~/.julia/packages/GMT/XBGE9/src/GMT.jl:280
[9] init()
@ GMT ~/.julia/packages/GMT/XBGE9/src/GMT.jl:260
[10] _include_from_serialized(path::String, depmods::Vector{Any})
@ Base ./loading.jl:696
[11] _require_from_serialized(path::String)
@ Base ./loading.jl:749
[12] _require(pkg::Base.PkgId)
@ Base ./loading.jl:1053
[13] require(uuidkey::Base.PkgId)
@ Base ./loading.jl:936
[14] require(into::Module, mod::Symbol)
@ Base ./loading.jl:923
during initialization of module GMT

Oh man you have a nose to fall into troubles. That’s Ubuntu stability installing a old GMT version (6.0.0) (> 2 years). I had to drop support that version in GMT.jl

As I see it, you either find a way to use packagers that install a newer version (there is a way but I don’t remember), or build from source, or remove it and let the default Conda version be installed.

I’m a happy Windows user, *nix is not good for my sanity.

1 Like

Many thanks for your big help anyway! Happy holidays…

Season greetings for you too.

1 Like

If you are on a long term support version of Ubuntu, this means, Ubuntu 20.04 or 18.04 you should be able to get GMT version 6.1.1 from the UbuntuGIS PPA

To add the UbuntuGIS PPA to your list of repositories do:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ubuntugis/ppa

as described here.

Then you should reinstall GMT and get the version 6.1.1
You might have to do the soft link again after reinstallation.

1 Like

Many thanks!

I’m able to build one from source files by following the below link:
https://github.com/GenericMappingTools/gmt/blob/master/BUILDING.md

Now I have GMT 6.3.0 running successfully on my machine and also on my Julia.

3 Likes

Nice. And sorry but haven’t had time to give this other suggestion. If you are building from source then with just a small extra step you can build the master version from Github. The interest is when this GMT issue is worked out, it will give native support for the Interrupted Good Homolosine projection. See the amazing images at at the issue page that Paul created with a twisted bash script.

1 Like