c - 在 VS Code 中使用 C++ 和 WSL 用于远程 ARM64 设备

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

我正在尝试构建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 到目标并在那里执行。

最佳答案

部分地,我成功了 - 我安装了 native 调试扩展 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机器上。可执行代码已启动并可以调试。

enter image description here

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

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

关于c - 在 VS Code 中使用 C++ 和 WSL 用于远程 ARM64 设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60007144/

相关文章:

windows-subsystem-for-linux - ConEmu 停止在 Windows 上使用 Bash

sql-server - 适用于 Linux 的 Windows 子系统 : Error while installing MSSQL Server

c - 结构指针类型转换错误分配使指针来自整数而不进行转换

c - 宏语法困惑

macos - 如何将青少年板添加到 VS Code 和 Arduino 插件?

javascript - 如何从 VSCode 中的多个位置运行 Jest 测试

windows - WSL stash/mnt/c/Users/

关于C中指针递减的困惑

c - 如何填充两个数组删除重复的数字

visual-studio-code - 如何将 KDiff3 配置为 VSCode 编辑器的合并工具