在VS Code中使用PCL库

本文详细介绍如何在VSCode中配置C++项目,包括c_cpp_properties.json、launch.json和tasks.json的设置,以及使用g++编译和GDB调试的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

文件目录

----.vscode(这个文件夹在文件中打开是隐藏的,Ctrl+h可显示)

--------c_cpp_properties.json(配置编译器环境)

--------launch.json(用于调试的配置文件)

--------tasks.json

----build

----src

----CMakeLists.txt

c_cpp_properties.json:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",   
    "tasks":[  // 可以有多个参数
        {
            "label": "build",       // 编译任务名
            "type": "shell",        // 编译任务的类型,通常为shell/process类型
            "command": "g++",       // 编译命令
            "args":[
                "-g",           
                "${workspaceFolder}/${fileBasename}",   // include path指令
                "-I", "/usr/local/include/pcl-1.9",    //根据自己安装的pcl修改下面路径
                "-I", "/usr/include/eigen3",
                "-I", "/usr/include/vtk-6.2",
                "-I", "/usr/include/qhull",
                "-I", "/usr/include/flann",
                "-I", "/usr/include/boost",
                // lib 库文件地址
                "-L", "/usr/local/lib",     
                "-l", "pcl_io",                           
                "-l", "pcl_visualization",
                "-l", "pcl_common",
                "-l", "vtkFiltering",
                "-l", "vtkCommon",
                "-l", "vtkRendering",
                "-l", "vtkGraphics",
                "-L", "/usr/include/x86_64-linux-gnu",  
                "-l", "boost_system",                
                "-o",                                    // 生成指定名称的可执行文件
                "${workspaceFolder}/${fileBasenameNoExtension}.out"  
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        },
        {
            "label": "cmakebuild",      
            "type": "shell", 
            "command": "cd build && cmake ../ && make",  
            "args": []
        }
    ] 
}

 launch.json

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) 启动",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/build/testground",//需要修改为自己工程生成得可执行文件
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}

tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",   
    "tasks":[  // 可以有多个参数
        {
            "label": "build",       // 编译任务名
            "type": "shell",        // 编译任务的类型,通常为shell/process类型
            "command": "g++",       // 编译命令
            "args":[
                "-g",           
                "${workspaceFolder}/${fileBasename}",   // include path指令
                "-I", "/usr/local/include/pcl-1.9",    //同样根据自己安装得PCL修改下面路径
                "-I", "/usr/include/eigen3",
                "-I", "/usr/include/vtk-6.2",
                "-I", "/usr/include/qhull",
                "-I", "/usr/include/flann",
                "-I", "/usr/include/boost",
                // lib 库文件地址
                "-L", "/usr/local/lib",     
                "-l", "pcl_io",                           
                "-l", "pcl_visualization",
                "-l", "pcl_common",
                "-l", "vtkFiltering",
                "-l", "vtkCommon",
                "-l", "vtkRendering",
                "-l", "vtkGraphics",
                "-L", "/usr/include/x86_64-linux-gnu",  
                "-l", "boost_system",                
                "-o",                                    // 生成指定名称的可执行文件
                "${workspaceFolder}/${fileBasenameNoExtension}.out"  
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        },
        {
            "label": "cmakebuild",      
            "type": "shell", 
            "command": "cd build && cmake ../ && make",  
            "args": []
        }
    ] 
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值