vscode配置c++ opencv环境

嗯。想着用c++来学习opencv,但是一上手做在配置环境上就遇到问题了,花了一天时间才解决,记录一下,下次配置的时候可以参考。

1.文件的下载

下载的gcc编译器:https://sourceforge.net/projects/mingw-w64/files/mingw-w64/
这里我下载的是:x86_64-posix-seh。使用别的版本时会出现各种问题,对作为新手的我来说,太不友好了。
这里再提一下,用于windows下的gcc编译器主要有这几类:Cygwin 、 MinGW、mingw-w64 。Cygwin没有用过,在用MinGW时会出现不支持c++线程的问题。这里附上下载地址:https://gcc.gnu.org/install/binaries.html
下载opencv:https://github.com/huihut/OpenCV-MinGW-Build

2.项目配置文件

#launch.json
{
    // 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": "g++.exe build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\mingw64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "g++.exe build active file"
        }
    ]
}


#c_cpp_properties.json
{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "c:\\OpenCV-MinGW-Build\\include",
                "c:\\OpenCV-MinGW-Build\\include\\opencv2",
                "c:\\OpenCV-MinGW-Build\\include\\opencv"

            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "D:/mingw64/bin/g++.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "msvc-x64"
        }
    ],
    "version": 4
}


总结

配置时出现的问题一般都是使用的文件版本不对,对各种的不支持。非常感谢那些提出问题和解决问题的人,我才能去参考它们的文章、回答,最终解决问题。这里附上参考的一些网站:

https://ithelp.ithome.com.tw/questions/10193134
https://github.com/chenyus0609/opencv-configuration-with-vscode
http://harryshaun.wang/mingw-w64seh%E8%BF%98%E6%98%AFsjlj/

在最后还遇到了一个问题:在这里插入图片描述
将需要链接的库文件复制到
C:\Windows\SysWOW64
C:\Windows\System32

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值