title: OpenCV: Error for failure to load library libopencv_calib3d.2.4.dylib
body: <p>I am trying to set up openCV (installed with homebrew) on my mac and ran the following the command. </p>
  
  <pre><code>g++ $(pkg-config --cflags --libs opencv) test.cpp -o Test&amp; ./test
  </code></pre>
  
  <p>However, I got this error:</p>
  
  <pre><code>[1] 7834
  dyld: Library not loaded: lib/libopencv_calib3d.2.4.dylib
    Referenced from: /usr/local/Cellar/opencv/2.4.9/include/./test
    Reason: image not found
  Trace/BPT trap: 5
  </code></pre>
  
  <p>I'm not sure what to do take care of this issue very novice to openCV and C++.</p>
  
  <p>The following shows the file structure. The test.cpp file is 2nd from the right along with the picture. I don't see how the program isn't finding the file as the name and location seem to be correct.</p>
  
  <p><img src="https://i.stack.imgur.com/95rRn.png" alt="enter image description here"></p>
  
  <p>test.cpp: </p>
  
  <pre><code>#include "opencv2/highgui/highgui.hpp"
  #include &lt;iostream&gt;
  
  using namespace cv;
  using namespace std;
  
  int main( int argc, const char** argv )
  {
      cout &lt;&lt; "test output line" &lt;&lt; endl;
       Mat img = imread("MyPic.JPG", CV_LOAD_IMAGE_UNCHANGED); //read the image data in the file "MyPic.JPG" and store it in 'img'
  
       if (img.empty()) //check whether the image is loaded or not
       {
            cout &lt;&lt; "Error : Image cannot be loaded..!!" &lt;&lt; endl;
            //system("pause"); //wait for a key press
            return -1;
       }
  
       namedWindow("MyWindow", CV_WINDOW_AUTOSIZE); //create a window with the name "MyWindow"
       imshow("MyWindow", img); //display the image which is stored in the 'img' in the "MyWindow" window
  
       waitKey(0); //wait infinite time for a keypress
  
       destroyWindow("MyWindow"); //destroy the window with the name, "MyWindow"
  
       return 0;
  }
  </code></pre>