Ask Your Question

Revision history [back]

segmentation fault - program compiles but imediate segfault when starting


I am having a problem that is really driving me crazy. I installed opencv and cannot find out what is causing the problem. I copied sample code from the tutorials to test my installation and I get a segfault whenever I start the program.

I reduced the code to identify the cause of the problem:

#include <stdio.h>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
//#include "opencv2/nonfree/features2d.hpp"
#include "opencv2/nonfree/nonfree.hpp"

using namespace cv;

void readme();

/** @function main */
int main( )
    std::cout << "hello!!!" << std::endl;

  Mat img_1;

  img_1 = imread("eagle.jpg");

  int minHessian = 400;

  SurfFeatureDetector detector( minHessian );

//  std::vector<KeyPoint> keypoints_1, keypoints_2;

//  detector.detect( img_1, keypoints_1 );

  return 0;

imread seems to be the culprit. If I exclude imread("eagle.jpg") it works fine. But if I put it into the code I get a segfault once I execute the code - even before "hello!!!" is printet.

This is where the debugger stops and gives me the segfault - if anybody can read anything from that. -> (0x7fffd492cdfc <+0x0000> lock incl (%rax))

I tried to install different versions of opencv without success.

I am using Ubuntu 14.04 with Qt Creator 3.0.1 and currently opencv 2.8.3

I greatly appreciate any help!