debugging - build.rs 中设置的 LD_LIBRARY_PATH 不会传递给 vscode 中的调试器
问题描述
所以我有两个简单的项目,一个有一个带有 c 库的子文件夹,它在运行时链接到另一个只是一个全新的 hello-world 应用程序。
我正在看这个:https ://www.youtube.com/watch?v= EzQ7YIIo1rY&t=3386s 非常好的教程视频,我正在研究使用 rust 插件设置 vscode。
所以我安装了rust analyser
和CodeLLDB
. 两者在这两个项目上都表现出色。到目前为止,一切都很好。然后我想在代码行debug
上方运行该选项fn main() {
。这非常适合简单的 hello world 应用程序。对于还链接到共享对象库的应用程序,它会尝试运行,但出现错误:
/home/user/bbb/development/rust_test/target/debug/rust_test: error while loading shared libraries: libadd_x64Linuxd.so: cannot open shared object file: No such file or directory
我对此并不感到惊讶,在其他 C++ 调试器中,我必须设置一个 settings/launcher.json 并在其中添加 LD_LIBRARY_PATH 。但是对于生锈,我不太确定。我原以为build.rs
会处理好这件事-其中包含:
use std::process::Command;
fn main() {
// EXTERN_C
// The name of the library to link to, i.e. like: -l<lib>
println!("cargo:rustc-link-lib=dylib=add_x64Linuxd");
// The library search path for linking, i.e. like -L<path>
println!("cargo:rustc-link-search=native=cadd/lib");
// The run-time library search path (LD_LIBRARY_PATH)
println!("cargo:rustc-env=LD_LIBRARY_PATH=cadd/lib");
}
所以路径都设置在这里。cargo run
工作,它链接到我的共享库。所以问题是我如何在运行调试器时传递/设置 LD_LIBRARY_PATH(就像在 youtube 视频中显示的那样,通过按下代码内的“调试”选项)?
解决方案
推荐阅读
- .htaccess - .htaccess : 从基于 TLD 的文件夹加载
- r - 如何将行条目更改为“未知”?
- python - 有没有办法将特殊的非字符键作为字符串类型转换为键类型?(例如“Key.f12”到实际的keyboard.Key.f12值)
- google-cloud-dataflow - GCD中内存使用的奇怪图表
- html - jquery Uncaught SyntaxError:无效或意外的令牌 - 错误
- regex - 正则表达式从最后一个中提取单词
- python - 基于键的字典交集,TypeError:列表索引必须是整数或切片,而不是索引
- flutter - Flutter 显示 JSON 数组中的值并点击更改索引
- selenium - Azure devops 硒测试计划
- java - 如何在运行时从父类访问子类变量?