# Julia in Ubuntu 20

**URL:** <https://forum.generic-mapping-tools.org/t/julia-in-ubuntu-20/1465>\
**Category:** GMT.jl Q&A\
**Created:** [March 16, 2021, 10:53am UTC](https://forum.generic-mapping-tools.org/t/julia-in-ubuntu-20/1465 "2021-03-16T10:53:11Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![marianoarnaiz](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/marianoarnaiz/32/971_2.png) [@marianoarnaiz](https://forum.generic-mapping-tools.org/u/marianoarnaiz)\
**Post date:** [March 16, 2021, 10:53am UTC](https://forum.generic-mapping-tools.org/t/julia-in-ubuntu-20/1465/1 "2021-03-16T10:53:11Z")

</div>

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

Stacktrace:

[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.

Stacktrace:

[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

---

<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:** [March 16, 2021, 12:48pm UTC](https://forum.generic-mapping-tools.org/t/julia-in-ubuntu-20/1465/2 "2021-03-16T12:48:42Z")

</div>

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.

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

```

---

<div class="post-metadata">

**Author:** ![marianoarnaiz](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/marianoarnaiz/32/971_2.png) [@marianoarnaiz](https://forum.generic-mapping-tools.org/u/marianoarnaiz)\
**Post date:** [March 16, 2021, 1:01pm UTC](https://forum.generic-mapping-tools.org/t/julia-in-ubuntu-20/1465/3 "2021-03-16T13:01:14Z")

</div>

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]

Stacktrace:  
[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

---

<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:** [March 16, 2021, 1:04pm UTC](https://forum.generic-mapping-tools.org/t/julia-in-ubuntu-20/1465/4 "2021-03-16T13:04:45Z")

</div>

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

```auto
gmt --show-library

```

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

---

<div class="post-metadata">

**Author:** ![marianoarnaiz](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/marianoarnaiz/32/971_2.png) [@marianoarnaiz](https://forum.generic-mapping-tools.org/u/marianoarnaiz)\
**Post date:** [March 17, 2021, 10:06am UTC](https://forum.generic-mapping-tools.org/t/julia-in-ubuntu-20/1465/5 "2021-03-17T10:06:32Z")

</div>

> [@Joaquim](#):
>
> ```auto
> run(`ldd /usr/lib/x86_64-linux-gnu/libgmt.so`)
> 
> ```

Yes, this works:

/usr/lib/x86\_64-linux-gnu/libgmt.so

---

<div class="post-metadata">

**Author:** ![marianoarnaiz](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/marianoarnaiz/32/971_2.png) [@marianoarnaiz](https://forum.generic-mapping-tools.org/u/marianoarnaiz)\
**Post date:** [March 17, 2021, 10:20am UTC](https://forum.generic-mapping-tools.org/t/julia-in-ubuntu-20/1465/6 "2021-03-17T10:20:46Z")

</div>

Maybe this is the problem?  
At:  
/usr/lib/x86\_64-linux-gnu/libgmt.so

ls _gmt_  
gives:  
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.

---

<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:** [March 17, 2021, 12:30pm UTC](https://forum.generic-mapping-tools.org/t/julia-in-ubuntu-20/1465/7 "2021-03-17T12:30:09Z")

</div>

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`

---

<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:** [March 17, 2021, 1:40pm UTC](https://forum.generic-mapping-tools.org/t/julia-in-ubuntu-20/1465/8 "2021-03-17T13:40:23Z")

</div>

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`

```auto
# 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?

---

<div class="post-metadata">

**Author:** ![marianoarnaiz](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/marianoarnaiz/32/971_2.png) [@marianoarnaiz](https://forum.generic-mapping-tools.org/u/marianoarnaiz)\
**Post date:** [March 18, 2021, 10:11am UTC](https://forum.generic-mapping-tools.org/t/julia-in-ubuntu-20/1465/9 "2021-03-18T10:11:13Z")

</div>

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

---

<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:** [March 18, 2021, 12:31pm UTC](https://forum.generic-mapping-tools.org/t/julia-in-ubuntu-20/1465/10 "2021-03-18T12:31:36Z")

</div>

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.

---

<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:** [March 18, 2021, 12:45pm UTC](https://forum.generic-mapping-tools.org/t/julia-in-ubuntu-20/1465/11 "2021-03-18T12:45:42Z")

</div>

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

> **[Troubles with gcc 9](https://discourse.julialang.org/t/troubles-with-gcc-9/47550)**
>
> A GMT user posted an issue that I was able to reproduce in WSL2 + gcc9. The error is ERROR: LoadError: LoadError: could not load library "/home/j/programs/lib/libgmt.so" /home/j/programs/julia/bin/../lib/julia/libstdc++.so.6: version...

---

<div class="post-metadata">

**Author:** ![marianoarnaiz](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/marianoarnaiz/32/971_2.png) [@marianoarnaiz](https://forum.generic-mapping-tools.org/u/marianoarnaiz)\
**Post date:** [March 18, 2021, 1:02pm UTC](https://forum.generic-mapping-tools.org/t/julia-in-ubuntu-20/1465/12 "2021-03-18T13:02:15Z")

</div>

> [@Joaquim](#):
>
> Troubles with gcc 9

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

---

<div class="post-metadata">

**Author:** ![murphybeck](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@murphybeck](https://forum.generic-mapping-tools.org/u/murphybeck)\
**Post date:** [January 18, 2022, 12:21pm UTC](https://forum.generic-mapping-tools.org/t/julia-in-ubuntu-20/1465/13 "2022-01-18T12:21:23Z")

</div>

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 [python](http://net-informations.com/python/iq/default.htm)3, 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`

---

<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 18, 2022, 1:11pm UTC](https://forum.generic-mapping-tools.org/t/julia-in-ubuntu-20/1465/14 "2022-01-18T13:11:51Z")

</div>

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