# Ccall to libgsl fails

**URL:** https://discourse.julialang.org/t/ccall-to-libgsl-fails/11957
**Category:** General Usage
**Tags:** question
**Created:** [June 26, 2018, 9:04am UTC](https://discourse.julialang.org/t/ccall-to-libgsl-fails/11957 "2018-06-26T09:04:35Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![stakaz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stakaz/32/4740_2.png) [@stakaz](https://discourse.julialang.org/u/stakaz)
#### Post date: [June 26, 2018, 9:04am UTC](https://discourse.julialang.org/t/ccall-to-libgsl-fails/11957/1 "2018-06-26T09:04:35Z")

</div>

Hello, I am trying to use ccall in julia for the first time and I can’t make a simple call to libgsl:

```julia
ccall((:gsl_sf_gamma_inc_Q, :libgsl), Cdouble, (Cdouble, Cdouble), 0.2, 0.2)

```

returns:

```julia
ERROR: LoadError: error compiling anonymous: could not load library "libgsl"
/usr/lib/libgsl.so: undefined symbol: cblas_ctrmv

```

What is the problem here? I have cblas installed…

Thanks for help.

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [June 26, 2018, 1:59pm UTC](https://discourse.julialang.org/t/ccall-to-libgsl-fails/11957/2 "2018-06-26T13:59:06Z")

</div>

It could be that your `/usr/lib/libgsl.so` has its library dependencies set up incorrectly so it doesn’t know where an appropriate cblas is (`ldd /usr/lib/libgsl.so`). You could try calling `Libdl.dlopen` on an appropriate cblas library before the `ccall`.

---

<div class="post-metadata">

### Author: ![stakaz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stakaz/32/4740_2.png) [@stakaz](https://discourse.julialang.org/u/stakaz)
#### Post date: [June 27, 2018, 8:51am UTC](https://discourse.julialang.org/t/ccall-to-libgsl-fails/11957/3 "2018-06-27T08:51:52Z")

</div>

I tried

```julia
Libdl.dlopen(:libgslcblas)

```

and

```julia
Libdl.dlopen(:libcblas)

```

But that did not solve the problem. However, I don’t know, how to determine, which library contains `cblas_ctrmv`.

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [June 27, 2018, 12:48pm UTC](https://discourse.julialang.org/t/ccall-to-libgsl-fails/11957/4 "2018-06-27T12:48:34Z")

</div>

Try dlopening with the `RTLD_LAZY|RTLD_DEEPBIND|RTLD_GLOBAL` flags.

---

<div class="post-metadata">

### Author: ![stakaz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stakaz/32/4740_2.png) [@stakaz](https://discourse.julialang.org/u/stakaz)
#### Post date: [June 28, 2018, 12:05pm UTC](https://discourse.julialang.org/t/ccall-to-libgsl-fails/11957/5 "2018-06-28T12:05:14Z")

</div>

Sorry, I don’t know how the dlopen call should look like with this flags. Could you help me with that?

Edit:just tried and was successful with

```julia
Libdl.dlopen(:libgslcblas, Libdl.RTLD_GLOBAL)
ccall((:gsl_sf_gamma_inc_Q, :libgsl), Cdouble, (Cdouble, Cdouble), 0.2, 0.3)

```
