# Using OrdinaryDiffEq.jl as a native ODE solver library from Rust with JuliaC --trim

**URL:** <https://discourse.julialang.org/t/using-ordinarydiffeq-jl-as-a-native-ode-solver-library-from-rust-with-juliac-trim/140333>\
**Category:** General Usage\
**Created:** [October 29, 2026, 9:55am UTC](https://discourse.julialang.org/t/using-ordinarydiffeq-jl-as-a-native-ode-solver-library-from-rust-with-juliac-trim/140333 "2026-10-29T09:55:46Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![yolhan\_mannes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yolhan_mannes/32/220485_2.png) [@yolhan\_mannes](https://discourse.julialang.org/u/yolhan_mannes)\
**Post date:** [October 30, 2026, 10:56pm UTC](https://discourse.julialang.org/t/using-ordinarydiffeq-jl-as-a-native-ode-solver-library-from-rust-with-juliac-trim/140333/11 "2026-10-30T22:56:05Z")

</div>

trimming doesn’t work with Enzyme but no trimming seems to work

```julia
using Enzyme

function juliafunc(x)
    return sum(x)
end

Base.@ccallable function cjuliafunc(px::Ptr{Float64},xlen::UInt64)::Float64
    x = unsafe_wrap(Vector{Float64},px,(xlen,))
    juliafunc(x)
end

Base.@ccallable function cjuliagrad(pg::Ptr{Float64},px::Ptr{Float64},xlen::UInt64) ::Cvoid
    g = unsafe_wrap(Vector{Float64},pg,(xlen,))
    x = unsafe_wrap(Vector{Float64},px,(xlen,))
    fill!(g,0.0)
    Enzyme.autodiff(Enzyme.Reverse,juliafunc,Duplicated(x,g))
    return Cvoid()
end

```

```rust
#[link(name = "ssplib", kind = "dylib")]
unsafe extern "C" {
    fn cjuliafunc(
        px: *mut f64,
        xlen: usize
    ) -> f64;
    fn cjuliagrad(
        pg: *mut f64,
        px: *mut f64,
        xlen: usize
    ) -> ();
}
fn main() {
    let mut x = vec![0.1;100];
    let s = unsafe {
        cjuliafunc(x.as_mut_ptr(), x.len())
    };
    println!("{}",s);
    let mut g = vec![0.0;100];
    unsafe {
        cjuliagrad(g.as_mut_ptr(),x.as_mut_ptr(), x.len())
    };
    println!("{:?}",g);
}

```

```julia-auto
juliac --output-lib ssplib --project="." ssprk.jl  
ln -sf ssplib.dylib libssplib.dylib     
RUSTFLAGS="-L native=$(pwd) -C link-arg=-Wl,-rpath,$(pwd)" cargo run --release

```

gives

```julia-auto
10
[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

```

however since no trimming if I bundle its pretty big

```julia-auto
juliac --output-lib ssplib --project="." ssprk.jl --bundle
yolhan@Mac testrs % du -sh ./lib
526M ./lib
yolhan@Mac testrs % du -sh ./share
 29M ./share

```

---

_[View the full topic](https://discourse.julialang.org/t/using-ordinarydiffeq-jl-as-a-native-ode-solver-library-from-rust-with-juliac-trim/140333)._
