title: Ubuntu Illegal Instruction opencv
body: <p>I recently installed opencv on Ubuntu 12.04.5 from the repository using this command.</p>
  
  <pre><code>sudo apt-get install libopencv-dev python-opencv
  </code></pre>
  
  <p>When I try to run the following code to confirm that it works properly I get an Illegal instruction (it compiled fine).</p>
  
  <pre><code>#include "opencv2/core/core.hpp"
  #include "opencv2/imgproc/imgproc.hpp"
  #include "opencv2/highgui/highgui.hpp"
  #include&lt;iostream&gt;
  
  using namespace std;
  
  int main(){
      cv::Mat img;
      img = cv::imread("RO.ppm");
      cout &lt;&lt; img.size() &lt;&lt; endl;
      return 0;
   }
  </code></pre>
  
  <p>I compiled using this command (due to undefined reference errors).</p>
  
  <pre><code>g++ -o test test.cpp $(pkg-config opencv --cflags --libs)
  </code></pre>
  
  <p>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?</p>