I’m trying to call this function
#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
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
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 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