title: Gcc/ld warning "liba" needed by "libb", not found, yet part of rpath
body: <p>I'm getting some warnings from <code>ld</code> about libraries that aren't found, but as far as I can tell it should be finding them. For example:</p>
  
  <p><code>/usr/bin/ld: warning: libleaf_util.so, needed by build/libleaf_lang.so, not found (try using -rpath or -rpath-link)</code></p>
  
  <p>This happens when I link the executable <code>build/unit_test</code> that includes <code>build/libleaf_lang.so</code>, as part of the command line(1). The linking is adding <code>rpath=$ORIGIN</code> to the executable and all the libraries, including the library <code>build/libleaf_lang.so</code>. If I do ldd on <code>build/libleaf_lang.so</code> it is able to find the library in question:</p>
  
  <p><code>libleaf_util.so =&gt; /home/src/leaf/misc/build/libleaf_util.so (0x00007fd7c2f90000)</code></p>
  
  <p>That would seem to indicate the required library is found. So why do I get the warning?</p>
  
  <p><em>Note this appears to only happen when I link using the path to the shared library, <code>build/libleaf_lang.so</code>. If I link by name <code>-lleaf_lang</code>, as I do for another executable, I do not get the warning.</em></p>
  
  <hr>
  
  <p>(1) <code>g++ -o build/unit_test -z origin -Wl,-rpath=\$ORIGIN build/boost_test_main.o build/test/expr_conversion_test.o build/test/statement_test.o build/test/expr_type_test.o build/test/full_type_test.o build/test/gmp_test.o build/test/intr_type_parse_test.o build/test/lambda_test.o build/test/number_test.o build/test/object_holder_test.o build/test/parse_test.o build/test/scope_test.o build/test/source_test.o build/test/type_converter_cost.o build/test/type_converter_fixate.o build/test/type_converter_function_call.o build/test/type_converter_match_function.o build/test/type_converter_parameterize_type.o build/test/type_converter_test.o build/test/type_converter_unify.o build/test/type_identifier_constrain.o build/test/type_identifier_determine.o build/test/type_identifier_expand.o build/test/type_identifier_get_spec.o build/test/type_identifier_infer.o build/test/unicode_test.o build/libleaf_lang.so build/libleaf_parser.so build/libleaf_util.so build/libleaf_runner.so build/libleaf_ir.so build/libleaf_ir_llvm.so -Lbuild/build/lib -Lsrc/build/lib -L/usr/lib -Lbuild -Lsrc -L/opt/llvm/install/lib -L/usr/lib -lboost_unit_test_framework -lboost_program_options -lrt -ldl -lboost_regex -lLLVM-3.8 -lgmp -lgmpxx -lboost_filesystem -lboost_system</code></p>