onnxruntime-rs icon indicating copy to clipboard operation
onnxruntime-rs copied to clipboard

Investigate static linking

Open nbigaouette opened this issue 5 years ago • 3 comments

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.

nbigaouette avatar Aug 07 '20 19:08 nbigaouette

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 avatar Aug 09 '21 15:08 pYtoner

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

pYtoner avatar Aug 10 '21 12:08 pYtoner

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

PhotonQuantum avatar Nov 03 '21 15:11 PhotonQuantum