title: Opencv linking libraries - Undefined Reference
body: <p>I tried to compile opencv codes on raspberry pi 3.However, it gives always "undefined reference ... " error, i think there is a problem with linking.</p>
  
  <p><strong>Compile:</strong></p>
  
  <pre><code>g++ `pkg-config --libs --cflags opencv` Face_Detection.cpp
  </code></pre>
  
  <p><strong>pkg-config opencv --libs:</strong></p>
  
  <pre><code>-L/opt/lib/ -L/opt/Deneme/opencv/a/ -opencv_calib3d -opencv_core 
  -opencv_features2d -opencv_flann -opencv_highgui -opencv_imgcodecs 
  -opencv_imgproc -opencv_ml -opencv_objdetect -opencv_photo -opencv_shape 
  -opencv_stitching -opencv_superres -opencv_videoio -opencv_video
  -opencv_calib3d_pch_dephelp -opencv_contrib_pch_dephelp 
  -opencv_core_pch_dephelp -opencv_features2d_pch_dephelp 
  -opencv_flann_pch_dephelp -opencv_gpu_pch_dephelp  
  -opencv_haartraining_engine -opencv_highgui_pch_dephelp
  -opencv_imgproc_pch_dephelp -opencv_legacy_pch_dephelp
  -opencv_ml_pch_dephelp -opencv_objdetect_pch_dephelp 
  -opencv_video_pch_dephelp
  </code></pre>
  
  <p><strong>pkg-config opencv --cflags:</strong></p>
  
  <pre><code>-I/opt/Deneme/Include/opencv -I/opt/Deneme/Include/
  </code></pre>
  
  <p><strong>opencv.pc file:</strong></p>
  
  <pre><code>includedir=/opt/Deneme/Include/opencv
  dir2=/opt/Deneme/Include/
  libdir=/opt/lib/
  libdir2=/opt/Deneme/opencv/a/
  
  Name: opencv
  Description: The opencv library
  Version: 3.x.x
  Cflags: -I${includedir} -I${dir2}
  Libs: -L${libdir} -opencv_calib3d -opencv_core -opencv_features2d -         opencv_flann    -opencv_highgui -opencv_imgcodecs -opencv_imgproc -opencv_ml -opencv_objdetect -opencv_photo -opencv_shape  -opencv_stitching  -opencv_superres  -opencv_videoio  -opencv_video  -L${libdir2} -opencv_calib3d_pch_dephelp -opencv_contrib_pch_dephelp -opencv_core_pch_dephelp -opencv_features2d_pch_dephelp -opencv_flann_pch_dephelp -opencv_gpu_pch_dephelp -opencv_haartraining_engine -opencv_highgui_pch_dephelp -opencv_imgproc_pch_dephelp -opencv_legacy_pch_dephelp -opencv_ml_pch_dephelp -opencv_objdetect_pch_dephelp -opencv_video_pch_dephelp
  </code></pre>
  
  <p><strong>error:</strong></p>
  
  <pre><code>Face_Detection.cpp:(.text+0x94): undefined reference to `cv::imread(std::string const&amp;, int)'
  
  Face_Detection.cpp:(.text+0xd8): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&amp;)'
  
  Face_Detection.cpp:(.text+0xec): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&amp;)'
  
  Face_Detection.cpp:(.text+0x128): undefined reference to `cv::resize(cv::_InputArray const&amp;, cv::_OutputArray const&amp;, cv::Size_&lt;int&gt;, double, double, int)'
  
  Face_Detection.cpp:(.text+0x1e8): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&amp;)'
  
  Face_Detection.cpp:(.text+0x218): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&amp;)'
  
  Face_Detection.cpp:(.text+0x250): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&amp;)'
  
  Face_Detection.cpp:(.text+0x26c): undefined reference to `cv::hconcat(cv::_InputArray const&amp;, cv::_InputArray const&amp;, cv::_OutputArray const&amp;)'
  
  Face_Detection.cpp:(.text+0x298): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&amp;)'
  
  Face_Detection.cpp:(.text+0x2c8): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&amp;)'
  </code></pre>
  
  <p>Thanks in advance.</p>