GMT Julia and ubuntu v18

I am aware that installing GMT with Julia only adds the wrapper. I have downloaded GMT and followed the directions from its git repository:

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

    You don't seem to have GMT installed and I don't install it automatically,
    so you will have to do it yourself.

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:

    using Libdl
    push!(Libdl.DL_LOAD_PATH, "/usr/lib/x86_64-linux-gnu/")
    push!(Libdl.DL_LOAD_PATH, "/usr/lib/x86_64-linux-gnu/")

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:

    You don't seem to have GMT installed and I don't install it automatically,
    so you will have to do it yourself.
    ERROR: LoadError: UndefVarError: GMT_Get_Version not defined
     [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

    using GMT
    using Test
    	run(`gmt --version`)	# Will fail if GMT is not installed.
    	global got_it = true
    	@test 1 == 1			# Let tests pass for sake of not triggering a PkgEval failure
    	global got_it = false
    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

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

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?

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

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

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

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


Following the Ubuntu instructions here ( I installed GMT and its dependencies by running the following commands:

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 ( 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…

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.

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?

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

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

Again, what does it says now?

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

Must be some remainings of previous settings/installation.

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?

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

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

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.

1 Like

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.

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.

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)