title: What is causing g++ to produce the error: "ld.exe cannot find -lopencv_world310"?
body: <p>I am attempting to build an application using g++ that is composed of several source files and also uses OpenCV 3.1.0. </p>
  
  <p>The CMD command is:</p>
  
  <pre><code>g++ -o home_surveillance -static -std=c++11 -m64 -IC:\Tools\OpenCV\opencv\build\include -LC:\Tools\OpenCV\opencv\build\x64\vc14\lib -lopencv_world310 configuration_manager.cpp events.cpp image_processor.cpp main.cpp response_module.cpp scheduler.cpp
  </code></pre>
  
  <p>The error produced is:</p>
  
  <pre><code>C:/Program Files/mingw-w64/x86_64-6.2.0-posix-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lopencv_world310
  collect2.exe: error: ld returned 1 exit status
  </code></pre>
  
  <p>I have been trying various things and searching for answers for a couple days now. I should note that the application builds properly in Visual Studio 2015. I have tried compiling the source files using g++ with the -c option and they all seem to compile fine. It is just the linking phase that produces an error. </p>
  
  <p><strong>Things I have tried:</strong></p>
  
  <ol>
  <li><p>Just about every possible combination of the specified command. (Modifying order of the options, -lopencv_world310.a, -lopencv_world310.lib, -lopencv_world310, -l"full_path"+"opencv_world310", etc..)</p></li>
  <li><p>Checked that all the paths and filenames are correct.</p></li>
  <li><p>Reinstalled mingw to make sure I was using mingw-w64 since this is a 64-bit application.</p></li>
  <li><p>Running CMD as admin thinking maybe CMD could not access the path specified with -L option.</p></li>
  <li><p>Googling and reading every post I could find. (Most posts about "ld.exe cannot find "library_name" are a result of someone using "library_name".a or "library_name".lib as input to the -l option).</p></li>
  <li><p>Reading mingw documentation on the use of GCC/g++ to ensure I wasn't missing anything obvious.</p></li>
  <li><p>Praying to Bjarne Stroustrup.</p></li>
  <li><p>Ritual sacrifice involving a Pentium 2.</p></li>
  </ol>