title: Mac OSX: ld cannot find an existing library
body: <p>I installed Google Test according to <a href="https://stackoverflow.com/questions/20746232/how-to-properly-setup-googletest-on-os-x-aside-from-xcode/21045113#21045113">How to properly setup googleTest on OS X aside from XCode</a>. I am trying to run</p>
  
  <pre><code>clang++ -I/usr/include -L/usr/lib t.cpp -lgtest
  </code></pre>
  
  <p>and I am receiving the error:</p>
  
  <pre><code>ld: library not found for -lgtest
  </code></pre>
  
  <p>However, the library exists:</p>
  
  <pre><code>ls /usr/lib/libgtest*
  /usr/lib/libgtest.0.dylib
  /usr/lib/libgtest.a
  /usr/lib/libgtest.dylib
  /usr/lib/libgtest.la
  /usr/lib/libgtest.lai         
  /usr/lib/libgtest_main.la
  /usr/lib/libgtest_main.0.dylib
  /usr/lib/libgtest_main.a
  /usr/lib/libgtest_main.dylib
  /usr/lib/libgtest_main.la
  /usr/lib/libgtest_main.lai
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>Here is the complete output:</p>
  
  <pre><code>clang++ -I/usr/include -L/usr/lib/ t.cpp -lgtest -v
         Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
         Target: x86_64-apple-darwin13.4.0
         Thread model: posix
         "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.9.0 -emit   -obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name t.cpp -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -mu   nwind-tables -target-cpu core2 -target-linker-version 241.9 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xct   oolchain/usr/bin/../lib/clang/6.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -I /   usr/include -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /Users/robi/Work2014/ut -ferror-limit 19 -fmessage-length 110 -stack-protecto   r 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.9.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fdiagnostics-show-option    -fcolor-diagnostics -vectorize-slp -o /var/folders/nm/drft6q4n64vckdwz4lpt48_00000gn/T/t-942578.o -x c++ t.cpp
         clang -cc1 version 6.0 based upon LLVM 3.5svn default target x86_64-apple-darwin13.4.0
         ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/incl   ude/c++/v1"
         ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/loca   l/include"
         ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/Library/   Frameworks"
     #include "..." search starts here:
     #include &lt;...&gt; search starts here:
         /usr/include
         /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1
         /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include
         /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
         /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include
     /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks (framework directo   ry)
         End of search list.
         "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version   _min 10.9.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -o a.out -L/usr/lib/ /va   r/folders/nm/drft6q4n64vckdwz4lpt48_00000gn/T/t-942578.o -lgtest -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.   xctoolchain/usr/bin/../lib/clang/6.0/lib/darwin/libclang_rt.osx.a
         ld: library not found for -lgtest
     clang: error: linker command failed with exit code 1 (use -v to see invocation)
  </code></pre>