// mean.c中代码如下:
double vectorMean(int *arr, int n)
{
int i, sum=0;
double mean;
for (i=0; i<n; i=i+1)
sum = sum + arr[i];
mean = sum / (double)n;
return mean;
}
之后采用gcc编译:gcc -Wall -shared -fPIC mean.c -o mean.so
相同路径,打开Julia:
using Libdl
l = Libdl.dlopen("mean")
# ERROR: could not load library "mean"
# mean.so: cannot open shared object file: No such file or directory
l = Libdl.dlopen("mean.so")
ERROR: could not load library "mean.so"
mean.so: cannot open shared object file: No such file or directory
# Stacktrace:
# [1] #dlopen#3(::Bool, ::typeof(dlopen), ::String, ::UInt32) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.2/Libdl/src/Libdl.jl:109
# [2] dlopen at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.2/Libdl/src/Libdl.jl:109 [inlined] (repeats 2 times)
# [3] top-level scope at REPL[7]:1
versioninfo()
Julia Version 1.2.0
Commit c6da87ff4b (2019-08-20 00:03 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Xeon(R) CPU E5-4610 v4 @ 1.80GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, broadwell)