title: Opencv on OSX, Undefined symbols for architecture x86_64: cv::imwrite not found
body: <p>I installed opencv by brew, I tried to reinstall for several times and it didn't help. I have googled for a lot of time but didn't find a valid way to solve this. </p>
  
  <p>I copied a valid opencv from my friend's mac, but the <code>imwrite</code> function  is still not found on my mac</p>
  
  <p>Please help.</p>
  
  <pre><code>bash: g++ $(pkg-config --cflags --libs opencv) BoxFilter.cc -o BoxFilter
  In file included from /usr/local/Cellar/opencv/3.3.0_3/include/opencv2/core.hpp:54:0,
                  from /usr/local/Cellar/opencv/3.3.0_3/include/opencv2/opencv.hpp:52,
                  from BoxFilter.cc:2:
  /usr/local/Cellar/opencv/3.3.0_3/include/opencv2/core/base.hpp:354:35: warning: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
  #   pragma GCC diagnostic ignored "-Winvalid-noreturn"
                                  ^
  Undefined symbols for architecture x86_64:
  "cv::imwrite(cv::String const&amp;, cv::_InputArray const&amp;, std::vector&lt;int, std::allocator&lt;int&gt; &gt; const&amp;)",referenced from:
      _main in ccO7bsE6.o
  ld: symbol(s) not found for architecture x86_64
  collect2: error: ld returned 1 exit status
  </code></pre>