# Mexjulia on Ubuntu

**URL:** https://discourse.julialang.org/t/mexjulia-on-ubuntu/1089
**Category:** Offtopic
**Tags:** question
**Created:** [December 21, 2016, 12:40pm UTC](https://discourse.julialang.org/t/mexjulia-on-ubuntu/1089 "2016-12-21T12:40:01Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [December 21, 2016, 12:40pm UTC](https://discourse.julialang.org/t/mexjulia-on-ubuntu/1089/1 "2016-12-21T12:40:01Z")

</div>

Hello,  
Is there anybody around who could help to debug the following error:

```julia
ufechner@TUD277255:~/00Software/mexjulia$ matlab
fatal: error thrown and no exception handler available.
Base.InitError(mod=:Sys, error=ErrorException("could not load symbol "jl_array_cconvert_cstring":
/usr/local/MATLAB/R2016b/bin/glnxa64/MATLAB: undefined symbol: jl_array_cconvert_cstring"))
rec_backtrace at /home/ufechner/julia/src/stackwalk.c:84
record_backtrace at /home/ufechner/julia/src/task.c:232
jl_throw at /home/ufechner/julia/src/task.c:550
jl_errorf at /home/ufechner/julia/src/builtins.c:78
jl_dlerror at /home/ufechner/julia/src/dlload.c:69 [inlined]
jl_dlsym at /home/ufechner/julia/src/dlload.c:24

```

More details see:  
[https://github.com/twadleigh/mexjulia/issues/32](https://github.com/twadleigh/mexjulia/issues/32)

Beeing able to write Julia code that can be called from Matlab would help me a lot in cooperating with colleagues from the University.

Uwe

---

<div class="post-metadata">

### Author: ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)
#### Post date: [December 21, 2016, 1:37pm UTC](https://discourse.julialang.org/t/mexjulia-on-ubuntu/1089/2 "2016-12-21T13:37:59Z")

</div>

According to [c++ - typeinfo, shared libraries and dlopen() without RTLD\_GLOBAL - Stack Overflow](http://stackoverflow.com/questions/5044993/typeinfo-shared-libraries-and-dlopen-without-rtld-global) matlab does not use `RTLD_GLOBAL`.

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [December 22, 2016, 6:46pm UTC](https://discourse.julialang.org/t/mexjulia-on-ubuntu/1089/3 "2016-12-22T18:46:22Z")

</div>

Hello,  
I do not really understand, how your answer relates to my question. I am not using RTLD\_GLOBAL. I want to rephrase my question:

- I am trying to call Julia from Matlab on Ubuntu;
- this crashes Matlab with the error message “undefined symbol: jl\_array\_cconvert\_cstring”;
- as far as I understand, it works fine on Mac and Windows.  
What I do NOT understand:
- why should the version of the C++ standard library that is linked to Matlab/ Julia should create any problem? If a pure C function interface is used, this should not matter.  
Does anybody understand, what could be the reason for this problem?  
Any comments welcome.  
Uwe

---

<div class="post-metadata">

### Author: ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)
#### Post date: [December 22, 2016, 6:58pm UTC](https://discourse.julialang.org/t/mexjulia-on-ubuntu/1089/4 "2016-12-22T18:58:27Z")

</div>

> [@ufechner7](#):
>
> I am not using RTLD\_GLOBAL

And neither is matlab, which is the issue, since julia cannot use dlsym to find the symbol.

> [@ufechner7](#):
>
> - why should the version of the C++ standard library that is linked to Matlab/ Julia should create any problem? If a pure C function interface is used, this should not matter.

C++ stdlib is irrelevant.

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [December 22, 2016, 7:06pm UTC](https://discourse.julialang.org/t/mexjulia-on-ubuntu/1089/5 "2016-12-22T19:06:08Z")

</div>

Why is this not a problem on Windows/ Mac then?

---

<div class="post-metadata">

### Author: ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)
#### Post date: [December 22, 2016, 7:25pm UTC](https://discourse.julialang.org/t/mexjulia-on-ubuntu/1089/6 "2016-12-22T19:25:59Z")

</div>

Dynamic loading is highly platform dependent. RTLD\_LOCAL may not exist or MATLAB may not be using it for whatever reason

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [December 22, 2016, 8:38pm UTC](https://discourse.julialang.org/t/mexjulia-on-ubuntu/1089/7 "2016-12-22T20:38:58Z")

</div>

This sounds more like Voodoo than like science. There must be a clean way to embed Julia into other languages.

---

<div class="post-metadata">

### Author: ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)
#### Post date: [December 22, 2016, 8:55pm UTC](https://discourse.julialang.org/t/mexjulia-on-ubuntu/1089/8 "2016-12-22T20:55:53Z")

</div>

Not sure what you are talking about. You need to make sure libjulia is dlopen’d with RTLD\_GLOBAL since otherwise you’ll get the error you see. This is not a julia issue at all but a MATLAB issue. You need to figure out how to embed something into MATLAB cleanly.

---

<div class="post-metadata">

### Author: ![ihnorton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihnorton/32/26_2.png) [@ihnorton](https://discourse.julialang.org/u/ihnorton)
#### Post date: [December 22, 2016, 9:29pm UTC](https://discourse.julialang.org/t/mexjulia-on-ubuntu/1089/9 "2016-12-22T21:29:26Z")

</div>

Perhaps try this suggestion in the thread linked earlier?

> <https://stackoverflow.com/questions/5044993/typeinfo-shared-libraries-and-dlopen-without-rtld-global/6488186#6488186>

It means to make this call: `dlopen("[...]/libjulia", RTLD_GLOBAL)` from the mexfile before doing anything else with libjulia.

> [@ufechner7](#):
>
> This sounds more like Voodoo than like science.

Accurate, sadly: much of “keeping the lights on” in modern computer systems ends up as a fight against build systems and concepts like “symbol coalescing” and “side-by-side assemblies” and “duplicate typeinfo”.

[https://twitter.com/bdash/status/769409852577677312](https://twitter.com/bdash/status/769409852577677312)

Not related to Julia (or even MATLAB, except acutely). We live in a fallen (digital) world, yet we struggle on.
