Click here to Skip to main content
15,920,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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]);

      return 0;


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/ 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

1 solution

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.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900