Ccall to libgsl fails

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

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

returns:

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.

1 Like

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.

I tried

Libdl.dlopen(:libgslcblas)

and

Libdl.dlopen(:libcblas)

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

Try dlopening with the RTLD_LAZY|RTLD_DEEPBIND|RTLD_GLOBAL flags.

2 Likes

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

Libdl.dlopen(:libgslcblas, Libdl.RTLD_GLOBAL)
ccall((:gsl_sf_gamma_inc_Q, :libgsl), Cdouble, (Cdouble, Cdouble), 0.2, 0.3)
1 Like