title: opencv mat CV_MAX_DIM in function setSize
body: <p>I have a small OpenCV code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  #include &lt;opencv2/core/core.hpp&gt;
  #include &lt;opencv2/highgui/highgui.hpp&gt;
  #include &lt;opencv2/imgproc/imgproc.hpp&gt;
  
  using namespace cv;
  
  int
  main(int argc, char* argv[])
  {
  
    cv::Mat mask_img = cv::imread("image.png");
    cv::imshow("window",mask_img);
  
    return 0;
  }
  </code></pre>
  
  <p>Yet when running I get the following error:</p>
  
  <blockquote>
    <p>OpenCV Error: Assertion failed (0 &lt;= _dims &amp;&amp; _dims &lt;= CV_MAX_DIM) in
    setSize, file /home/box/OpenCV-2.4.3/modules/core/src/matrix.cpp, line
    88 terminate called after throwing an instance of 'cv::Exception'<br>
    what():  /home/box/OpenCV-2.4.3/modules/core/src/matrix.cpp:88: error:
    (-215) 0 &lt;= _dims &amp;&amp; _dims &lt;= CV_MAX_DIM in function setSize</p>
    
    <p>Aborted</p>
  </blockquote>
  
  <p>I'm using OpenCV 2.4.3 on kubuntu linux, compiled from source.</p>
  
  <p>How can I resolve this error?</p>
  
  <p>I solved it myself, just use</p>
  
  <pre><code> g++ bla2.cpp `pkg-config opencv --cflags --libs` -o bla
  </code></pre>
  
  <p>Do not use your own linking libraries in addition like -lopencv_core etc</p>