nbigaouette / onnxruntime-rs

Rust wrapper for Microsoft's ONNX Runtime (version 1.8)
Apache License 2.0
283 stars 100 forks source link

Investigate static linking #10

Open nbigaouette opened 4 years ago

nbigaouette commented 4 years ago

Dynamic linking of libonnxruntime.so is annoying. If binaries are not run from cargo, they cannot find it (rpath issue). This makes running examples through a debugger difficult.

Static linking might help in that regard. Not sure if upstream supports it though.

pYtoner commented 3 years ago

Static linking should be possible. I really would like to see this too. I am not sure at all how one would do this though.

pYtoner commented 3 years ago

The best workaround I found is to copy the dynamic libs into the sysroot/lib folder. Where rust keeps its libs.

I made a build.rs to do it automatically: https://gist.github.com/pYtoner/edf32c2a1f9d298e67c8752757e18eaa

PhotonQuantum commented 3 years ago

The upstream doesn't recommend static linking against libonnxruntime due to third party dependencies and potentially a debug allocator. https://github.com/microsoft/onnxruntime/issues/8555