Where are the shared and static libraries of the Rust standard library?
Asked Answered
D

2

6

I am trying to compile my Rust project with dynamic linking to reduce the size and provide .so (or .dll on Windows) files with the application just like Qt does for Android. I read Why are Rust executables so huge? and compiled with

cargo rustc  -- -C prefer-dynamic

When I run my program, I get this error:

 % target/debug/t_pro 
target/debug/t_pro: error while loading shared libraries: libstd-a021829e87e39dcf.so: cannot open shared object file: No such file or directory
Definitive answered 22/11, 2018 at 18:42 Comment(2)
Please provide additional information: what program are you trying to build? Which compiler version, which toolchain, and which host OS?Artina
Most operating systems come with tools to search the hard drive for files of a specific name. Have you tried one of those?Potheen
P
2

The libraries are installed wherever you chose to install Rust. I use rustup on macOS, so they are installed in ~/.rustup/toolchains/*whatever*/lib/ for me.

Use your operating system's tools to search for files of a specific name.

See also:

Potheen answered 22/11, 2018 at 21:37 Comment(0)
D
9

I got an answer on Reddit.

rustc --print=sysroot

In my case, the .so files are in /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib and .rlib are in /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib.

Definitive answered 23/11, 2018 at 12:1 Comment(2)
export LD_LIBRARY_PATH+=:$(rustc --print=sysroot)/lib worked perfect for meAintab
I'm on mac, so I had to use DYLD_FALLBACK_LIBRARY_PATH="$DYLD_FALLBACK_LIBRARY_PATH:$(rustc --print=sysroot)/lib"Barlow
P
2

The libraries are installed wherever you chose to install Rust. I use rustup on macOS, so they are installed in ~/.rustup/toolchains/*whatever*/lib/ for me.

Use your operating system's tools to search for files of a specific name.

See also:

Potheen answered 22/11, 2018 at 21:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.