segmentation fault - program compiles but imediate segfault when starting
Hi,
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!
Cheers
Start by building OpenCV in DEBUG mode instead of RELEASE mode. This way you will get actual error information instead of simple segmentation faults. But best guess is that your linker libraries are probably not connected correctly! Also, OpenCV 2.8.3 doesnt exist, so I guess it is 2.3.8 but why the hell not use the most recent stable version 2.4.9? IT has TONS of fixed bugs!
You have a double topic [here}(http://answers.opencv.org/question/43611/segmentation-fault-when-imread-is-active/). Since this one contains more answers, I will close down the other!
sorry, thanks for the hint