# Could not load symbol with ccall

**URL:** <https://discourse.julialang.org/t/could-not-load-symbol-with-ccall/88231>\
**Category:** General Usage\
**Tags:** question, ccall\
**Created:** [October 4, 2022, 1:31pm UTC](https://discourse.julialang.org/t/could-not-load-symbol-with-ccall/88231 "2022-10-04T13:31:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ovt](https://avatars.discourse-cdn.com/v4/letter/o/87869e/32.png) [@ovt](https://discourse.julialang.org/u/ovt)\
**Post date:** [October 4, 2022, 1:31pm UTC](https://discourse.julialang.org/t/could-not-load-symbol-with-ccall/88231/1 "2022-10-04T13:31:58Z")

</div>

I’m trying to call this function

```julia
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <string.h>

#define datatype double /* type of the elements in y */

static void simplexproj_Condat(datatype* y, datatype* x, 
const unsigned int length, const double a) {
	datatype*	aux = (x==y ? (datatype*)malloc(length*sizeof(datatype)) : x);
	datatype* aux0=aux;
	int auxlength=1; 
	int auxlengthold=-1;	
	double	tau=(*aux=*y)-a;
	int i=1;
	for (; i<length; i++) 
		if (y[i]>tau) {
			if ((tau+=((aux[auxlength]=y[i])-tau)/(auxlength-auxlengthold))
			<=y[i]-a) {
				tau=y[i]-a;
				auxlengthold=auxlength-1;
			}
			auxlength++;
		} 
	if (auxlengthold>=0) {
		auxlength-=++auxlengthold;
		aux+=auxlengthold;
		while (--auxlengthold>=0) 
			if (aux0[auxlengthold]>tau) 
				tau+=((*(--aux)=aux0[auxlengthold])-tau)/(++auxlength);
	}
	do {
		auxlengthold=auxlength-1;
		for (i=auxlength=0; i<=auxlengthold; i++)
			if (aux[i]>tau) 
				aux[auxlength++]=aux[i];	
			else 
				tau+=(tau-aux[i])/(auxlengthold-i+auxlength);
	} while (auxlength<=auxlengthold);
	for (i=0; i<length; i++)
		x[i]=(y[i]>tau ? y[i]-tau : 0.0); 
	if (x==y) free(aux0);
}

```

with the following julia code

```julia
using Libdl

const ccode_lib = joinpath(@ __DIR__ ,"libsimproj.so")
Libdl.dlopen(ccode_lib)
x = rand(10)
y = rand(10)

ccall((:simplexproj_Condat,ccode_lib),
       Cvoid,
       (Ptr{Cdouble},Ptr{Cdouble},Cuint,Cdouble),
       y,x,length(x),1.0)

```

but I have this error

```julia
ERROR: could not load symbol "simplexproj_Condat":
/path/to/libsimproj.so: undefined symbol: simplexproj_Condat

```

I don’t understand why… the ouput of `nm libsimproj.so | grep simplex` is  
`0000000000001139 t simplexproj_Condat`

I compiled the library with the command `gcc -shared -fPIC -o libsimproj.so condat_simplexproj.c`

version info is

```julia
Julia Version 1.8.2
Commit 36034abf260 (2022-09-29 15:21 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 12 × Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, skylake)
  Threads: 1 on 12 virtual cores

```

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [October 4, 2022, 1:58pm UTC](https://discourse.julialang.org/t/could-not-load-symbol-with-ccall/88231/2 "2022-10-04T13:58:58Z")

</div>

> [@ovt](#):
>
> I don’t understand why… the ouput of `nm libsimproj.so | grep simplex` is  
> `0000000000001139 t simplexproj_Condat`

Lower `t` means that is local, I suspect it has to do with the fact the function is `static`, if I remove that annotation the symbol is marked as `T` in the output of `nm` and I can call the function regularly.

---

<div class="post-metadata">

**Author:** ![ovt](https://avatars.discourse-cdn.com/v4/letter/o/87869e/32.png) [@ovt](https://discourse.julialang.org/u/ovt)\
**Post date:** [October 4, 2022, 2:02pm UTC](https://discourse.julialang.org/t/could-not-load-symbol-with-ccall/88231/3 "2022-10-04T14:02:24Z")

</div>

Indeed, thanks !
