ubuntu18.04 配置vscode的C++/C环境+opencv

目录

一、安装vscode

二、安装C/C++插件

三、配置调试和编译文件

3.1 tasks.json文件----生成out文件

3.2 launch.json文件----执行out文件

四 执行

五 OPENCV编译环境

5.1 配置依赖

5.2 配置opencv

5.2 配置vscode环境

5.2.1 c_cpp_properties.json

5.2.2 task.josn

六 添加头文件路径

6.1 c_cpp_properties.json

6.2 task.josn

七 各种报错

7.1  缺少libjasper.so.1

7.2 编译出错/bin: error while loading shared libraries: libopencv_highgui.so.3.2: cannot open


先说下 win上我没配置成功。只配置成功linux了。

 

一、安装vscode

我使用anaconda安装的,可以参考vscode的主页,有安装方式。

二、安装C/C++插件

按Ctrl + shift + X,搜索C/C++并安装。安装它就行。

三、配置调试和编译文件

3.1 tasks.json文件----生成out文件

为了方便在VScode里编译C++代码,我们可以将类似g++ -g main.cpp等g++命令写入VScode的任务系统。

按ctrl+shift+p打开命令行,输入Tasks: Run task,回车!!!,会出现如下提示:

    No task to run found. configure tasks...

再回车,

    Create tasks.json file from template

然后选择:

   Others Example to run an arbitrary external command.

生成默认的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",
            "command": "g++",
            "args": ["-g", "${file}", "-o", "${fileBasenameNoExtension}.out"]
        }
    ]
}

这里的label为任务名,我们将”label"= "echo"改为”label"= "build"。
由于我们的指令是g++,这里将”command“=”echo Hello“改为”command“=”g++“。
然后添加g++的参数args。如果我们的g++指令为:g++ -g main.cpp,这里可以把参数设置为如下:

3.2 launch.json文件----执行out文件

选中文件夹/cpp文件,按Ctrl+shift+D,点击左侧的Debug按钮,选择添加配置(Add configuration),然后选择C++(GDB/LLDB)回车!!将自动生成launch.json文件,修改内容如下:

            "program": "enter program name, for example ${workspaceFolder}/a.out",

改为

            "program": "${workspaceFolder}/${fileBasenameNoExtension}.out",

{
    // 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": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/${fileBasenameNoExtension}.out",
            "args
  • 4
    点赞
  • 66
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

颐水风华

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值