title: Adding run-time shared library search-path to executable at compile-time | clang | Ubuntu
body: <p>An executable I'm compiling needs the <code>rpath</code> to a library file at runtime. Currently, I'm compiling the executable with,</p>
  
  <pre><code>clang -O3 -mllvm -polly -mllvm -polly-target=gpu vector_add.c -lGPURuntime -ldl
  </code></pre>
  
  <p>And then using either of the following methods to provide the <code>rpath</code>,</p>
  
  <ol>
  <li>Adding it to <code>LD_LIBRARY_PATH</code></li>
  <li>Using <code>patchelf --set-rpath $RPATH a.out</code></li>
  </ol>
  
  <p>I need a method to indicate the <code>rpath</code> in the <code>clang ....</code> command itself.</p>
  
  <p>I'm running clang5.0.0-svn(7cf8dd5ce168bed45b57e019149e33300c56f94b) and llvm-svn(85f508cd9dba8a982471d98c4f649fb0d63f3451) with ld.gold in Ubuntu 14.04 x86_64.</p>
  
  <p>Thank You !</p>