Skip to content

Instantly share code, notes, and snippets.

@goropikari
Created January 8, 2018 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goropikari/9b2396b6edc93a98368a46d0d98b428e to your computer and use it in GitHub Desktop.
Save goropikari/9b2396b6edc93a98368a46d0d98b428e to your computer and use it in GitHub Desktop.
#include <stdio.h>


int calc(double x[], int len)
{
  for (int i = 0; i < len; i++) {
    x[i] = x[i] * 2;
  }
  return 0;
}

making shared library

gcc -Wall -shared -o calc.so -lm -fPIC test.c

General syntax

ccall((:function_name, "./used_library"), return_type, (argument_type,), argument)
ccall((:calc, "./calc.so"), Void, (Ptr{Cdouble}, Int64), x, length(x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment