Julia in Ubuntu 20

Hi guys. Sorry to bother you again with the Julia wrapper.

I just installed it in Ubuntu (I am turning some Julia people to GMT hahaha) and it won’t wrap.
Here is what it says. I have tried the usual turn arounds (force recompile, etc).
GMT work as it should in the system. I don’t understand why it won’t pickup the lib.

julia> using GMT

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

ERROR: LoadError: LoadError: could not load library “/usr/lib/x86_64-linux-gnu/libgmt.so”

/usr/lib/x86_64-linux-gnu/libgmt.so: no se puede abrir el archivo del objeto compartido: No existe el archivo o el directorio


[1] GMT_Create_Session at /home/user/.julia/packages/GMT/zIejk/src/libgmt.jl:26 [inlined] (repeats 2 times)

[2] top-level scope at /home/user/.julia/packages/GMT/zIejk/src/get_enums.jl:7

[3] include(::Function, ::Module, ::String) at ./Base.jl:380

[4] include at ./Base.jl:368 [inlined]

[5] include(::String) at /home/user/.julia/packages/GMT/zIejk/src/GMT.jl:1

[6] top-level scope at /home/user/.julia/packages/GMT/zIejk/src/GMT.jl:204

[7] include(::Function, ::Module, ::String) at ./Base.jl:380

[8] include(::Module, ::String) at ./Base.jl:368

[9] top-level scope at none:2

[10] eval at ./boot.jl:331 [inlined]

[11] eval(::Expr) at ./client.jl:467

[12] top-level scope at ./none:3

in expression starting at /home/user/.julia/packages/GMT/zIejk/src/get_enums.jl:7

in expression starting at /home/user/.julia/packages/GMT/zIejk/src/GMT.jl:203

ERROR: Failed to precompile GMT [5752ebe1-31b9-557e-87aa-f909b540aa54] to /home/user/.julia/compiled/v1.5/GMT/EoU0j_wBMyH.ji.


[1] error(::String) at ./error.jl:33

[2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1305

[3] _require(::Base.PkgId) at ./loading.jl:1030

[4] require(::Base.PkgId) at ./loading.jl:928

[5] require(::Module, ::Symbol) at ./loading.jl:923

I guess that I will never understand how unix is supposed to work. I have GMT.jl working in a Centos 8 (GMT installed with package manager) and in a Ububtu (WSL and GMT compiled by me).
Can you please post the output of this, run from a Julia REPL but without trying to load the GMT package.

run(`ldd /usr/lib/x86_64-linux-gnu/libgmt.so`)

I get:

ldd: /usr/lib/x86_64-linux-gnu/libgmt.so: No existe el archivo o el directorio
ERROR: failed process: Process(ldd /usr/lib/x86_64-linux-gnu/libgmt.so, ProcessExited(1)) [1]

[1] pipeline_error at ./process.jl:525 [inlined]
[2] run(::Cmd; wait::Bool) at ./process.jl:440
[3] run(::Cmd) at ./process.jl:438
[4] top-level scope at none:1

That’s even more strange but maybe is giving us a clue. What does it print on the bash shell

gmt --show-library

It has to print /usr/lib/x86_64-linux-gnu/libgmt.so otherwise where would it get that lib address?

Yes, this works:


Maybe this is the problem?

ls gmt
libgmt.so.6 libgmt.so.6.0.0

So… Maybe the wrapper is looking for “libgmt.so” exactly and does not recognize the extra 6.0.0 in the name. Where can I change the name to see if it works.

So you are saying that gmt --show-library prints a name of a library that does not exist on your system??? That must be a GMT bug

Solution for the moment. Make a symbolic link. Something like

ln -s libgmt.so.6 libgmt.so

OK, I think I found the reason. At compile time GMT sores the name of the shared lib, but ONLY up to the .so part. e.g. in CMakeList.txt

# Get suffix for libraries
set (_lib_suffix ${CMAKE_SHARED_LIBRARY_SUFFIX})

# Get name of GMT core library
get_target_property (_name gmtlib RUNTIME_OUTPUT_NAME)
get_target_property (_prefix gmtlib PREFIX)
set (GMT_CORE_LIB_NAME ${_prefix}${_name}${_lib_suffix})

but now some Linux packages decided to not create the symbolic link to the .so library and all logic breaks down. The solution is either to create the symbolic link manually or setting an environment variable GMT_LIBRARY pointing to, in this case, /usr/lib/x86_64-linux-gnu/libgmt.so.6. Shit.

@seisman, @pwessel anything we can do about this?

Hi all… So … apparently the problem with the library was just step 1. After using the solution given by @Joaquim (ln -s libgmt.so.6 libgmt.so), Julia still didn’t want to load the module because:

julia `GLIBCXX_3.4.26’ not found

So I did:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc
sudo apt-get upgrade libstdc++6

Then copy the library to Julia’s directory:
cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 ~/JuliaPro-1.5.3-1/Julia/lib/julia/

Now all is fine… hope it helps someone else with the same problem

1 Like

Hi Mariano, thanks for figuring this out. I’m having that same error when trying to run the CI tests in Ubuntu latest and could not understand why. Now I think I do. Linux practiced again the lightness with which it deals with the backward compatibility issues, so probably your Julia was built with an older version of glib than the GMT package and the result is this. Maybe when you upgrade to Julia1.6 this will go … for a while.

Where do I have my head. It was only half an year ago

I see there is some consistency in this error. Maybe Julia itself needs more flexibility when installing.

Most of the time these are dependency-issues. You need to install a package called python-dev. This package includes header files, a static library and development tools for building Python modules, extending the Python interpreter or embedding Python in applications. When encountering this error please note before the error it may say you are missing a package or header file — you should find those and install them and verify if it works

For Python 2.x use:

$ sudo apt-get install python-dev

If you using python3, try to replace python-dev with python3-dev

For a specific version of Python 3, replace x with the minor version in

$ sudo apt-get install python3.x-dev

This answer has nothing to do with the issues discussed in this thread.