vscode for c++ 开发及编译记录

vscode for c++ 开发及编译记录,第1张

vscode for c++ 开发及编译记录
  1. 交叉编译 – arrch64
    vscode 配置新增自定义 kits – toolchains-gcc-linaro-6.3.1

    .vscode/cmake-kits.json

    [
       {
           "name": "toolchains-gcc-linaro-6.3.1",
           "toolchainFile": "${workspaceFolder}/cmake/toolchain-aarch64.cmake"
       }
    ]
    

    cmake/toolchain-aarch64.cmake

    set(CMAKE_SYSTEM_NAME Linux)
    set(CMAKE_SYSTEM_PROCESSOR aarch64)
    
    # tools 设置编译工具链目录
    set(tools /data/release/toolchains/gcc/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu)
    set(CMAKE_C_COMPILER ${tools}/bin/aarch64-linux-gnu-gcc)
    set(CMAKE_CXX_COMPILER ${tools}/bin/aarch64-linux-gnu-c++)
    
    set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
    set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
    set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
    set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
    
  2. vscode 远程调试

    本地环境

    {
        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "name": "aarch64-linux-gnu-g++",
                "type": "cppdbg",
                "request": "launch",
                "program": "${command:cmake.launchTargetPath}",
                "args": [],
                "stopAtEntry": false,
                "cwd": "${fileDirname}",
                "environment": [],
                "externalConsole": false,
                "MIMode": "gdb",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ],
                "miDebuggerPath": "/data/release/toolchains/gcc/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gdb",	// gdb 路径
                "miDebuggerServerAddress": "192.168.1.110:19126"
            }
        ]
    }
    

    远程环境

    gdbserver 192.168.1.110:19126 ./xxxxx	# xxxxx 准备调试的程序
    

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4750470.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-08
下一篇 2022-11-08

发表评论

登录后才能评论

评论列表(0条)

保存