Rust标准库的共享库和静态库在哪里?

yoj*_*oru 1 dynamic-linking rust

我正在尝试使用动态链接编译我的Rust项目以减小大小并在应用程序中提供.so(或Windows上的.dll)文件,就像Qt对Android一样.我读过为什么Rust可执行文件如此庞大?并编译

cargo rustc  -- -C prefer-dynamic
Run Code Online (Sandbox Code Playgroud)

当我运行我的程序时,我收到此错误:

 % 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
Run Code Online (Sandbox Code Playgroud)

yoj*_*oru 5

在Reddit上得到了答案.

rustc --print=sysroot
Run Code Online (Sandbox Code Playgroud)

在我的例子中,.so文件在/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib和.rlib中/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib.


She*_*ter 2

这些库将安装在选择安装 Rust 的任何位置。我在 macOS 上使用rustup,因此它们已为我安装~/.rustup/toolchains/*whatever*/lib/

使用操作系统的工具搜索特定名称的文件。

也可以看看: