VScode+wsl2+openmp的编译运行环境设置

在.vscode文件夹下新建三个文件:

1. tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "C/C++: g++ build active file",
            "command": "/usr/bin/g++",
            "args": [
                "-fopenmp",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "group": "build",
            "problemMatcher": [
                "$gcc"
            ],
            "detail": "调试器生成的任务。"
        },
        {
            "type": "cppbuild",
            "label": "C/C++: g++ 生成活动文件",
            "command": "/usr/bin/g++",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "调试器生成的任务。"
        }
    ]
}

2. launch.json

{
    "version": "2.0.0",
    "configurations": [
        {
            "name": "C/C++: g++ build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "将反汇编风格设置为 Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++ build active file",
            "miDebuggerPath": "/usr/bin/gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "miDebuggerArgs": "-q",
            "stopAtEntry": false,
            "setupCommands": [
                {
                    "text": "handle SIGPIPE nostop noprint pass",
                    "description": "Let gdb ignore SIGPIPE",
                    "ignoreFailures": true
                }
            ],
            "launchCompleteCommand": "exec-run",
            "sourceFileMap": {
                "/mnt/c": "c:\\",
                "/usr/local": "c:\\usr\\local"
            }
        }
    ]
}

 

3. c_cpp_peoperties.json

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/g++",
            "cStandard": "c17",
            "cppStandard": "gnu++17",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}
  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当谈到美化和搭建Linux开发环境时, VS Code,WSL和Windows Terminal都是非常有用的工具。 首先,VS Code是一款流行的开源代码编辑器,可通过安装各种插件进行美化。你可以选择喜欢的主题和语法高亮方案,以配合你的个人喜好。 其次,WSL(Windows Subsystem for Linux)是一种在Windows上运行Linux二进制文件的兼容层。通过安装WSL,你可以在Windows中使用真正的Linux发行版,如Ubuntu或Debian。这样,你就可以在Windows系统中体验和开发Linux环境下的应用程序。 最后,Windows Terminal是Windows新的命令行终端。它支持多个选项卡以及各种自定义设置,如调整配色方案、字体大小和字体类型等。你可以使用Windows Terminal将多个终端会话放置在一个窗口中,从而提高工作效率。 要搭建Linux开发环境,首先你需要安装WSL以及喜欢的Linux发行版。然后,你可以通过安装VS Code插件和扩展来优化你的开发体验。安装一些常用的扩展,如Python、C++或Node.js,以根据你的需求进行开发。 当你需要在Windows环境中执行Linux命令时,你可以打开Windows Terminal,并选择WSL作为默认终端。这样,你就可以通过Windows Terminal运行和管理你的Linux环境。 总结起来,VS Code,WSL和Windows Terminal是一些功能强大且易于使用的工具,它们可以帮助你美化和搭建Linux开发环境。使用这些工具,你可以在Windows中轻松进行Linux开发,并以最佳方式执行命令和编辑代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值