title: Run simple C++ OpenCV on Mac Terminal
body: <p>I'm a complete beginner with cpp and opencv. I would like to compile and run this simple Program that lets me display an image. This works if I run the code inside XCode but if I try it using clang in the console it throws me a</p>
  
  <pre><code>linker command failed with exit code 1 (use -v to see invocation)
  </code></pre>
  
  <p>I had add these "linker flags" in Xcode to get opencv to run so I assume I need to somehow install them globally too. HHow would I achieve this? </p>
  
  <pre><code>#include &lt;opencv2/core/core.hpp&gt;
  #include &lt;opencv2/highgui/highgui.hpp&gt;
  #include &lt;opencv2/imgproc/imgproc.hpp&gt;
  #include &lt;iostream&gt;
  
  using namespace cv;
  using namespace std;
  
  int main(int argc, char** argv) {
  
  if (argc != 2) {
      cout &lt;&lt; "Bitte zu ladendes Bild als Parameter angeben." &lt;&lt; endl;
      return -1;
  }
  
  Mat image;
  image = imread(argv[1], CV_LOAD_IMAGE_COLOR);
  
  if (!image.data) {
      cout &lt;&lt;  "Bild " &lt;&lt; argv[1] &lt;&lt; " wurde nicht gefunden." &lt;&lt; std::endl ;
      return -1;
  }
  
  namedWindow("OpenCV Window", WINDOW_AUTOSIZE);
  imshow("OpenCV Window", image);
  
  cout &lt;&lt; "Image width: " &lt;&lt; image.cols &lt;&lt; ", image height: " &lt;&lt; 
  image.rows &lt;&lt; endl;
  
  waitKey(0);
  
  return 0;
  } 
  </code></pre>
  
  <p>These are the Linker Flags inside Xcode:</p>
  
  <pre><code>-lopencv_calib3d -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_video -lopencv_videoio -lopencv_videostab
  </code></pre>