launch.json rust in vscode
在第一个JSON文件中,参数是[ "build", "--bin", "unsafe-counter"]
。cargo build --bin unsafe-counter
命令是用于构建二进制文件unsafe-counter
的。在这个配置中,VSCode将会构建这个应用程序,然后使用参数"/root/lab/laertes/rewrite-workspace/bzip2/rust/c2rust-lib.rs"
来启动它。注意,这种方式需要你的程序能接受并处理这个参数。
在第二个JSON文件中,参数是[ "run", "--release", "--bin", "unsafe-counter", "--", "/root/lab/laertes/rewrite-workspace/bzip2/rust/c2rust-lib.rs" ]
。cargo run --release --bin unsafe-counter -- /root/lab/laertes/rewrite-workspace/bzip2/rust/c2rust-lib.rs
命令将会在release模式下运行这个二进制文件,并且给它传递"/root/lab/laertes/rewrite-workspace/bzip2/rust/c2rust-lib.rs"
参数。然而,这种方式存在一个问题,这就是你没有指定在哪个工作目录下运行这个命令。你需要确定你的unsafe-counter
二进制文件是在/root/lab/unsafe-counter
目录下,而且它能在那里找到所有它需要的资源。否则,你可能会得到一些关于找不到文件或目录的错误。
为什么json1对
{
"version": "0.2.0",
"configurations": [
{
"sourceLanguages": ["rust"],
"type": "lldb",
"request": "launch",
"name": "Launch unsafe-counter",
"cargo": {
"args": [ "build", "--bin", "unsafe-counter"],
"filter": {
"name": "unsafe-counter",
"kind": "bin"
}
},
"args": ["/root/lab/laertes/rewrite-workspace/bzip2/rust/c2rust-lib.rs"],
"cwd": "/root/lab/unsafe-counter"
}
]
}
json2错
{
"version": "0.2.0",
"configurations": [
{
"sourceLanguages": ["rust"],
"type": "lldb",
"request": "launch",
"name": "Launch unsafe-counter",
"cargo": {
"args": [
"run",
"--release",
"--bin",
"unsafe-counter",
"--",
"/root/lab/laertes/rewrite-workspace/bzip2/rust/c2rust-lib.rs"
],
"filter": {
"name": "unsafe-counter",
"kind": "bin"
}
},
"cwd": "/root/lab/unsafe-counter"
}
]
}