Skip to content

Commit 011fd61

Browse files
committed
update juliac readme instrucitons
1 parent fd61f71 commit 011fd61

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,31 @@ The fixed-point controller behaves roughly the same in this case, but artifacts
198198
## Compilation using JuliaC
199199
The file `examples/juliac/juliac_pid.jl` contains a JuliaC-compatible interface that can be compiled into a C-callable shared library using JuliaC. To compile the file, run the following from the `examples/juliac` folder:
200200
```bash
201-
julia +nightly --project <PATH_TO_JULIA_REPO>/julia/contrib/juliac.jl --output-lib juliac_pid --trim=unsafe-warn --compile-ccallable juliac_pid.jl
201+
julia +nightly --project <PATH_TO_JULIA_REPO>/julia/contrib/juliac.jl --output-lib juliac_pid --experimental --trim=unsafe-warn --compile-ccallable juliac_pid.jl
202202
```
203-
where `<PATH_TO_JULIA_REPO>` should be replaced with the path to the Julia repository on your system. The command will generate a shared library `juliac_pid` that can be called from C. The file `examples/juliac/juliac_pid.h` contains the C-compatible interface to the shared library.
203+
where `<PATH_TO_JULIA_REPO>` should be replaced with the path to the Julia repository on your system. The command will generate a shared library `juliac_pid` that can be called from C. The file `examples/juliac/juliac_pid.h` contains the C-compatible interface to the shared library. The C program may be compiled with a command like
204+
```bash
205+
export LD_LIBRARY_PATH=<PATH_TO_JULIA_REPO>/julia/usr/lib:$LD_LIBRARY_PATH
206+
gcc -o pid_program test_juliac_pid.c -I <PATH_TO_JULIA_REPO>/julia/usr/include/julia -L<PATH_TO_JULIA_REPO>/julia/usr/lib -ljulia -ldl
207+
```
208+
and then run by
209+
```bash
210+
./pid_program
211+
```
212+
which should produce the output
213+
```
214+
DiscretePIDs/examples/juliac> ./pid_program
215+
Loading juliac_pid.so
216+
Loaded juliac_pid.so
217+
Finding symbols
218+
Found all symbols!
219+
calculate_control! returned: 1.000000
220+
calculate_control! returned: 2.000000
221+
calculate_control! returned: 3.000000
222+
calculate_control! returned: 3.000000
223+
calculate_control! returned: 3.000000
224+
```
225+
At the time of writing, this requires a nightly version of julia
204226

205227

206228
## See also

0 commit comments

Comments
 (0)