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.
- Host: GitHub
- URL: https://github.com/jbytecode/juliac
- Owner: jbytecode
- License: mit
- Created: 2025-04-10T19:55:37.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-07-05T19:00:22.000Z (7 months ago)
- Last Synced: 2025-07-05T20:22:08.733Z (7 months ago)
- Language: Julia
- Homepage:
- Size: 40 KB
- Stars: 13
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.