GDB调试和opencv的使用

本文介绍了如何使用GDB进行调试,包括段错误调试,通过实例详细讲解了每一步操作。接着,讲述了OpenCV的安装过程以及如何编写代码打开图片和摄像头,解答了在使用OpenCV过程中可能遇到的问题,如视频文件读取和waitKey函数的作用。
摘要由CSDN通过智能技术生成

GDB调试和opencv的使用

GDB调试

1.先创建一个RevertNum.c文件

jzddyy@ubuntu:~/opencv-3.4.11/my_build_dir$ nano RevertNum.c

代码如下(功能为对一个整型数进行反转输出)

#include <stdio.h> 
void ShowRevertNum(int iNum) 
{
            while (iNum > 10)         
{
     printf("%d", iNum % 10);
iNum = iNum / 10;         }         
printf("%d\n", iNum); 
} 
int main(void) 
{
            int iNum;         
printf("Please input a number :");         
scanf("%d", &iNum);         
printf("After revert : ");         
ShowRevertNum(iNum); } 

编译.c文件

jzddyy@ubuntu:~/opencv-3.4.11/my_build_dir$ gcc -o RevertNum -g RevertNum.c

启动GDB

jzddyy@ubuntu:~/opencv-3.4.11/my_build_dir$ gdb RevertNum
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from RevertNum...done.
(gdb) 

利用l显示代码及行号

(gdb) l
1	#include <stdio.h> 
2	void ShowRevertNum(int iNum) 
3	{
            while (iNum > 10)         
4	{
     printf
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值