I am completely new to C and I just wanted to see if someone can help me with making a C function available to ccall
. As a MWE I have
// example.c file
#include <stddef.h>
void radix_sort(char **strings) {
const size_t len = sizeof(strings) / sizeof(char *);
strings[0] = strings[len];
return;
}
So I wanted to make radix_sort available for ccall
. So these are the steps I have followed
- Compile the above using
gcc example.c -shared -fPIC -o d:/c_lib/example.so
- Set the environment variable
LD_LIBRARY_PATH
tod:/c_lib/
. I tried to follow this - In Julia I tried
hello = ccall((:radix_sort,"example"), Void, (Vector{String},),["b","a"])
But it gave me an error
ERROR: error compiling anonymous: could not load library "example"
The specified module could not be found.
So it seems that Julia doesn’t know where the library is. So I also tried to compile it like this
gcc -fPIC -c example.c
gcc -shared d:/c_lib/example.so example.o
and it gave me the same error.
Please help guide me on how to do this. I am on Windows 10 64bit. It seems something I don’t undertand about where Julia is looking for the shared library; it may have to do with my total lack of experience with C given this is the first time I am writing in C.
Background:
I am trying to make a faster string sorting algorithm in Julia but I wanted to benchmark it against a ccall function