An open API service indexing awesome lists of open source software.

https://github.com/jbytecode/juliac

Examples for Julia's generating small binary executables and libraries feature.
https://github.com/jbytecode/juliac

Last synced: 7 months ago
JSON representation

Examples for Julia's generating small binary executables and libraries feature.

Awesome Lists containing this project

README

          

# juliac

Examples for Julia's generating small binary executables and libraries feature.

Note that this feature is still under development.

## My Initial Blog Post

https://jbytecode.github.io/juliac/

This blog post represents the requirements and command line arguments of the compiler.

## The Discourse Entry

https://discourse.julialang.org/t/where-is-juliac-developed/113004?u=jbytecode

This Discourse post the entry point of my journey.

## How to use this repo?

- The `download.sh` script downloads the required scripts from the Julia's GitHub repository. The latest versions of these scripts are already included in this repo. To update them, type

```shell
> cd juliac
> ./download.sh
> cd ..
```

in the OS terminal.

### Hello World

```shell
> make hello
```

generates the `hello` binary using `hello.jl`.

Please review the `Makefile` file to build other examples.

### Calling Julia Library Function from C

The files `mylib.c`, `mylibcaller.c`, and `mylib.jl` represents calling Julia-generated dynamic library functions from within C. Here is the skeleton:

```julia
module MyLibrary

Base.@ccallable function myfunc(x::Float64)::Float64
return x^2
end

end
```

and here the caller:

```C
#include

double myfunc(double);

int main(){
double result = myfunc(5.0);
printf("Result is %f\n", result);
return 0;
}
```

where `myfunc` is defined in Julia.

```Shell
> make mylibcaller
```

compiles Julia and C files together and generates the shared library and the caller executable.