【问题标题】:Using C++ and WSL in VS Code for remote ARM64 device在远程 ARM64 设备的 VS Code 中使用 C++ 和 WSL
【发布时间】:2020-05-17 07:34:02
【问题描述】:

我正在尝试构建main.cpp 文件

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
   int count=0;
   vector<string> msg {"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};

   for (const string& word : msg)
   {
      count++;
      cout << word << " ";
   }
   cout << endl;
}

Using C++ and WSL in VS Code 但它结束了。这个例子我可以直接在 WSL 上构建

x86: g++-7 main.cpp -o main.x86_64
ARM64: aarch64-linux-gnu-g++ main.cpp -o main.arm64

我的 task.json 文件是

    {
        "type": "shell",
        "label": "aarch64-linux-gnu-g++",
        "command": "/usr/bin/aarch64-linux-g++",
        "args": [
            "-g",
            "${file}",
            "-o",
            "${fileDirname}/${fileBasenameNoExtension}.arm64"
        ],
        "options": {
            "cwd": "/usr/bin"
        },
        "problemMatcher": [
            "$gcc"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        }
    }

如何在 VSCode 中为远程 ARM 目标机器构建(交叉编译)并远程调试?

我有目标 ssh 机器的 IP 地址,并且在 Win10/WSL 上本地安装了“aarch64-linux-gnu-gcc”...我可以手动完成,这意味着交叉-编译它并 scp-ing 到目标并在那里执行。

【问题讨论】:

  • 我不知道为什么会这样,但是将tasks.json 传递给 gcc 命令是错误的。 tasks.json 文件处于活动状态时,您是否使用了“编译文件”?
  • 是的,这是我的错误,并尝试在错误激活的文件上运行构建任务:(

标签: c visual-studio-code windows-subsystem-for-linux


【解决方案1】:

部分地,我成功了——我安装了原生调试扩展Native Debug of WebFreak

    {
        "type": "gdb",
        "request": "launch",
        "name": "Launch Program (SSH)",
        "target": "/home/root/peterb/bin/main.arm64",
        "cwd": "${workspaceRoot}",
        "preLaunchTask": "aarch64-linux-gnu-g++",
        "ssh": {
           "host": "10.171.89.215",
           "cwd": "/home/root/peterb/bin",
           "user": "root",
           "password": "",
           "port": 22,
           "useAgent": false,
           "forwardX11": false
        }
    }

我手动将可执行文件main.arm64main.cpp复制到arm64机器上。可执行代码已启动,可以调试了。

"preLaunchTask": "aarch64-linux-gnu-g++", 执行“自动构建”。

现在我想从主机的项目工作区自动复制到目标机器?

【讨论】:

  • 你不能使用另一个VS任务吗?还是使用 aarch64-linux-gnu-g++ 任务的前置任务?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-07-02
  • 2018-11-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多