title: How to install OpenCV lib under OS X Mavericks and make it work with Code::Blocks
body: <p>I would like to use OpenCV library with Code::Blocks.</p>
  <p>I have already installed OpenCV with the following command line :</p>
  <blockquote>
  <p>sudo port install opencv</p>
  </blockquote>
  <p>The above command created multiple opencv folders in /opt/local/include/, /opt/local/var/macports/software/, /opt/local/var/macports/sources/ and /opt/local/share/.</p>
  <p>What should I do now to make it work with Code::Blocks ?</p>
  <p>[EDIT 24.06]</p>
  <p>Thanks to cyriel, I have managed to install OpenCV and make it work with QT Creator.</p>
  <p>To install Homebrew and OpenCV just type the following command lines :</p>
  <blockquote>
  <p>ruby -e &quot;$(curl -fsSL <a href="https://raw.github.com/Homebrew/homebrew/go/install" rel="nofollow noreferrer">https://raw.github.com/Homebrew/homebrew/go/install</a>)&quot;</p>
  <p>brew doctor</p>
  <p>brew tap homebrew/science</p>
  <p>brew install opencv</p>
  </blockquote>
  <p>Then, set cyriel's project settings and try to compile and execute following source code :</p>
  <pre><code>#include &lt;opencv2/core/core.hpp&gt;
  #include &lt;opencv2/highgui/highgui.hpp&gt;
  #include &lt;iostream&gt;
  
  using namespace cv;
  using namespace std;
  
  int main()
  {
      Mat image;
      image = imread(&quot;/image-path/image-filename.image-format&quot;, CV_LOAD_IMAGE_COLOR);
  
      if(! image.data )
      {
          cout &lt;&lt;  &quot;Could not open or find the image&quot; &lt;&lt; std::endl ;
          return -1;
      }
  
      namedWindow( &quot;Display window&quot;, WINDOW_AUTOSIZE );
      imshow( &quot;Display window&quot;, image );
      waitKey(0);
      return 0;
  }
  </code></pre>
  <p>and it works just fine !</p>
  <p><strong>Regarding Code::Blocks</strong></p>
  <p>In Build options &gt; Linker Settings, I have linked all the *.a and *.dylib files that are in the /usr/include/lib/ folder.</p>
  <p>In Build options &gt; Search directories &gt; Compiler, I have added /usr/local/lib, /usr/local/include/opencv and /usr/local/include folders</p>
  <p>In Build options &gt; Search directories &gt; Linker, I have added /usr/local/lib and /usr/local/include/opencv</p>
  <p>I am not familiar with external libraries so I m not really sure if my configuration is correct but it doesn't seem to compile correctly.</p>
  <blockquote>
  <p>-------------- Run: Debug in ImgDownsampling-V1 (compiler: GNU GCC Compiler)---------------</p>
  <p>Checking for existence:
  /Users/Universe/Desktop/Coding/ImgDownsampling-V1/bin/Debug/ImgDownsampling-V1
  Executing: osascript -e 'tell app &quot;Terminal&quot;' -e 'activate' -e 'do
  script &quot;/Applications/CodeBlocks.app/Contents/MacOS/cb_console_runner
  DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:.:/usr/local/lib:/usr/local/include/opencv
  /Users/Universe/Desktop/Coding/ImgDownsampling-V1/bin/Debug/ImgDownsampling-V1
  &quot;' -e 'end tell'  (in
  /Users/Universe/Desktop/Coding/ImgDownsampling-V1/.)</p>
  </blockquote>
  <p>Terminal doesn't show up...</p>
  <p>[EDIT 24.06]</p>
  <p>I have tried to change settings and managed to make it work !</p>
  <p>Same Code::Blocks configuration as before except that I have cleared all the folders in Build options &gt; Search directories &gt; Linker.</p>