该程序的分段错误 [英] Segmentation fault for this program

查看:47
本文介绍了该程序的分段错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我用C ++做一些图像处理工作.为此,我使用CImg.h库,觉得对我的工作很有帮助.

这是我写的一小段代码,它们只读取并显示图像.



hi all,

I do some image processing work in C++. For this i use CImg.h library which i feel is good for my work.

Here is small piece of code written by me which just reads an image and displays it.



#include "../CImg.h"

 using namespace cimg_library;

int main(int argc,char**argv)
 {
      CImg img(argv[1]);
      img.display();

      return 0;

 }


当我输入lena.pgm作为此代码时,它可以正常工作并显示图像.好像我给出了其他图像,例如存在于同一工作目录中的ddnl.pgm一样,我得到分割错误".

当我使用gdb运行代码时,我得到的输出如下:

程序收到信号SIGSEGV,分段错误. /lib/libc.so.6中strlen()中的0x009823a3缺少单独的debuginfo,请使用:debuginfo-install glibc-2.9-2.i686 libX11-1.1.4-5.fc10.i386 libXau-1.0.4-1.fc10 .i386 libXdmcp-1.0.2-6.fc10.i386 libgcc-4.3.2-7.i386 libstdc ++-4.3.2-7.i386 libxcb-1.1.91-5.fc10.i386

有人可以告诉我问题是什么吗?以及解决方法.

谢谢大家


When i give lena.pgm as input this code it works fine and displays the image. Where as if i give some other image, for example ddnl.pgm which is present in the same working directory i get "Segmentation Fault".

When i ran the code using gdb i get the output as follows:

Program received signal SIGSEGV, Segmentation fault. 0x009823a3 in strlen () from /lib/libc.so.6 Missing separate debuginfos, use: debuginfo-install glibc-2.9-2.i686 libX11-1.1.4-5.fc10.i386 libXau-1.0.4-1.fc10.i386 libXdmcp-1.0.2-6.fc10.i386 libgcc-4.3.2-7.i386 libstdc++-4.3.2-7.i386 libxcb-1.1.91-5.fc10.i386

Can some one please tell me what the problem is? and how to solve it.

Thank you all

推荐答案

天哪知道CImg是什么,或在哪里找到它.无论哪种方式,常识和逻辑都会告诉我们,如果程序能够工作或不工作,则基于您指向的图像,那么问题就出在您试图打开的文件上.或者,问题在于该库只能打开某些类型的文件,而您只有一个可以使用的文件.

首先,请确保这些图像在支持它们的另一个程序中工作.然后,我对路径进行了硬编码,看看会发生什么.然后,我将检查图像以查看它们是否具有不同的位深/压缩率等.或者,也许在所有这些之前,我将使用调试器来跟踪代码以查看哪一行被炸毁,并阅读该代码的一般区域中的任何注释以了解问题.
Goodness knows what CImg is, or where you found it. Either way, common sense and logic tells us that if the program works or does not work, based on what image you point it to, then the problem is with the files you''re trying to open. OR, the problem is that the library can only open certain types of files, and you only have one that it was written to work with.

I''d start by making sure these images work in another program that supports them. Then I''d hard code the path and see what happens. Then I''d check the images to see if they are a different bit depth/compression/etc. OR, perhaps before all of that, I''d use the debugger to trace through the code to see which line is blowing up and read any comments in that general area of the code to understand the issue.


这篇关于该程序的分段错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆