Difficulty using ccall

Your C code and Makefile are fine. This is what I get with those files:

$ make
gcc  -c -Wall -fPIC calc_mean.c -o calc_mean.o
gcc  -shared -fPIC -o libmean.so calc_mean.o
$ julia 
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.8.0 (2022-08-17)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> ccall((:mean, "./libmean.so"), Cdouble, (Cdouble, Cdouble), 1.0, 2.0)
1.5

I agree that something seems to be strange with your Julia installation and/or runtime environment.

2 Likes