0

I am new to opencv and Eclipse. I have copied the code from this link:
http://docs.opencv.org/doc/tutorials/introduction/linux_eclipse/linux_eclipse.html#linux-eclipse-usage

#include <cv.h>
#include <highgui.h>

using namespace cv;

int main( int argc, char** argv )
{
    Mat image;
    image = imread( argv[1], 1 );

    if( argc != 2 || !image.data )
    {
        printf( "No image data \n" );
        return -1;
    }

  namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
  imshow( "Display Image", image );

  waitKey(0);

  return 0;
}

After successful compilation, on debugging, I got this error message:

Error in final launch sequence
Failed to execute MI command:
-file-exec-and-symbols /home/jeni/workspace/FusionImage/src/FusionImage.cpp
Error message from debugger back end:
"/home/jeni/workspace/FusionImage/src/FusionImage.cpp": not in executable format: File format not recognized
"/home/jeni/workspace/FusionImage/src/FusionImage.cpp": not in executable format: File format not recognized  

I'm using this on Ubuntu 14.04 LTS.
Why am i getting this? And how to solve this?

explorer
  • 283
  • 4
  • 10
  • 1
    Looks like your IDE is trying to debug your source code, and not the exectuable that was created. – PaulMcKenzie Feb 24 '15 at 16:25
  • @PaulMcKenzie how to create the executable? – explorer Feb 24 '15 at 16:42
  • Did you consider compiling on the command line, probably with `g++ -Wall -g FusionImage.cpp -lopencv -o FusionImage`? Eclipse is confusing you... – Basile Starynkevitch Feb 24 '15 at 16:50
  • @BasileStarynkevitch I'm getting this error: ' FusionImage/src/FusionImage.cpp:1:16: fatal error: cv.h: No such file or directory #include ^ compilation terminated.' – explorer Feb 24 '15 at 16:56
  • @jeniShah You have to specify the path of where your include files are. http://stackoverflow.com/questions/558803/how-to-add-a-default-include-path-for-gcc-in-linux – PaulMcKenzie Feb 24 '15 at 17:12
  • @PaulMcKenzie, After compilation, executing the binary gives this error message: `terminate called after throwing an instance of std::logic_error what(): basic_string::_S_construct null not valid Aborted (core dumped)` – explorer Feb 24 '15 at 17:43
  • 2
    @jeniShah You have a bug in your program. Now is the time to start debugging. I would suggest you start a new question concerning why your program crashes, as this is separate from the issue of building your program (hint, why are you not checking `argc` *before* accessing `argv[1]`?) – PaulMcKenzie Feb 24 '15 at 17:49
  • @PaulMcKenzie I think there may be some other issue. The code is copied from official site of opencv. – explorer Feb 24 '15 at 17:56
  • 1
    @jeniShah According to the code, if you started the program with no command-line arguments, then your program is in deep trouble. There won't be an `argv[1]` to access. Look at your code again, and imagine if you started the program by just entering the program name. Regardless of where you got the code from, the error should be obvious to you (not checking to make sure that there are `n` command line arguments given). – PaulMcKenzie Feb 24 '15 at 17:59

0 Answers0