title: Mac OSX, Qt Creator and Google Test
body: <p>I installed Google Test according to this <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>. So, lib files ended up in <code>/usr/lib/</code>.
  But I was unable to compile with command</p>
  
  <pre><code>clang++ -I/usr/include -L/usr/lib t.cpp -lgtest
  </code></pre>
  
  <p>since I have received</p>
  
  <pre><code>ld: library not found for -lgtest
  </code></pre>
  
  <p>I have found this post <a href="https://stackoverflow.com/questions/25373055/ld-library-path-not-working-under-os-x-10-9">ld library path not working under OS X 10.9</a>, so I copied the libraries to another location: <code>/opt/local/lib</code>. Now I am able to compile my code using</p>
  
  <pre><code>clang++ -I/opt/local/include -L/opt/local/lib/ t.cpp -lgtest
  </code></pre>
  
  <p>However, I can not remove them from <code>/usr/lib</code>. If I do, I can not run the compiled program:</p>
  
  <pre><code>dyld: Library not loaded: /usr/local/lib/libgtest.0.dylib
  Referenced from: /path_to_code/./a.out
  Reason: image not found
  Trace/BPT trap: 5
  </code></pre>
  
  <p>Maybe this is only some setting in my OS?</p>
  
  <p>After being able to compile from command line, I tried from Qt Creator. I added to the project file</p>
  
  <pre><code>INCLUDEPATH += /opt/local/include
  LIBS += -L/opt/local/lib -L/usr/lib -lgtest
  </code></pre>
  
  <p>but I have unresolved symbols:</p>
  
  <pre><code>   Undefined symbols for architecture x86_64:
     "testing::internal::EqFailure(char const*, char const*, std::string const&amp;, std::string const&amp;, bool)", referenced from:
     testing::AssertionResult testing::internal::CmpHelperEQ&lt;int, int&gt;(char const*, char const*, int const&amp;, int const&amp;) in main.o
     "std::string::c_str() const", referenced from:
     testing::AssertionResult::message() const in main.o
     "std::basic_stringstream&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;::str() const", referenced from:
     std::string testing::PrintToString&lt;int&gt;(int const&amp;) in main.o
     "std::ostream::operator&lt;&lt;(int)", referenced from:
     void testing_internal::DefaultPrintNonContainerTo&lt;int&gt;(int const&amp;, std::ostream*) in main.o
     "std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;::~basic_string()", referenced from:
     testing::AssertionResult testing::internal::CmpHelperEQ&lt;int, int&gt;(char const*, char const*, int const&amp;, int const&amp;) in main.o
     testing::internal::scoped_ptr&lt;std::string&gt;::reset(std::string*) in main.o
     "std::basic_stringstream&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;::basic_stringstream(std::_Ios_Openmode)", referenced from:
     std::string testing::PrintToString&lt;int&gt;(int const&amp;) in main.o
     "std::basic_stringstream&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;::~basic_stringstream()", referenced from:
     std::string testing::PrintToString&lt;int&gt;(int const&amp;) in main.o
     "std::ios_base::Init::Init()", referenced from:
     ___cxx_global_var_init in main.o
     "std::ios_base::Init::~Init()", referenced from:
     ___cxx_global_var_init in main.o
         ld: symbol(s) not found for architecture x86_64
     clang: error: linker command failed with exit code 1 (use -v to see invocation)
         make: *** [ut1] Error 1
         22:52:06: The process "/usr/bin/make" exited with code 2.
     Error while building/deploying project ut1 (kit: Desktop Qt 5.3 clang 64bit)
         When executing step "Make"
  </code></pre>
  
  <p>Can somebody explain me what is happening there?</p>