I recently installed opencv on Ubuntu 12.04.5 from the repository using this command.
sudo apt-get install libopencv-dev python-opencv
When I try to run the following code to confirm that it works properly I get an Illegal instruction (it compiled fine).
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include<iostream>
using namespace std;
int main(){
cv::Mat img;
img = cv::imread("RO.ppm");
cout << img.size() << endl;
return 0;
}
I compiled using this command (due to undefined reference errors).
g++ -o test test.cpp $(pkg-config opencv --cflags --libs)
Update: Commenting out the cout line does not change the result and I've triple checked that RO.ppm exists in this directory (even if it didn't imread doesn't throw an error with illegal or not found input in my experience). I guess my question is two-fold what causes illegal instruction errors and how do I fix it?