title: Compiling boost flags with explicit location on boost binaries
body: <p>I am compiling a project that needs <code>boost::filesystem</code>. I have included the following flags in my compilation step:</p>
  
  <pre><code>g++ -Wall -ggdb -Werror -std=c++11 -lboost_system 
      -lboost_filesystem -I /custom/path/to/boost_1_67_0 
      -o build/main build/cp.o build/walk.o build/diff.o build/main.o
  </code></pre>
  
  <p>and I get an error:</p>
  
  <pre><code>build/cp.o: In function `boost::filesystem::relative(boost::filesystem::path const&amp;, boost::filesystem::path const&amp;)':
  /custom/path/boost_1_67_0/boost/filesystem/operations.hpp:690: undefined reference to `boost::filesystem::detail::relative(boost::filesystem::path const&amp;, boost::filesystem::path const&amp;, boost::system::error_code*)'
  build/cp.o: In function `boost::filesystem::weakly_canonical(boost::filesystem::path const&amp;)':
  /custom/path/boost_1_67_0/boost/filesystem/operations.hpp:728: undefined reference to `boost::filesystem::detail::weakly_canonical(boost::filesystem::path const&amp;, boost::system::error_code*)'
  collect2: error: ld returned 1 exit status
  make: *** [build] Error 1
  </code></pre>
  
  <p>I suspect that this is due to the fact that I have various other <code>boost::filesystem</code> binaries, some of which don't have <code>relative</code> and <code>weakly_canonical</code> in their versions. I don't really know where to supply the argument to specify the location of the binaries either. I suspect it's something to do with the flags <code>lboost_system</code> and <code>lboost_filesystem</code> where I can supply the location.</p>
  
  <p><strong>I am currently in process of building the .so's but I can see that the filesystem .so is already successfully built at <code>/custom/path/boost_1_67_0/bin.v2/libs/filesystem/build/gcc-4.8.5/release/threading-multi/libboost_filesystem.so.1.67.0</code>,</strong> so I want to point to that in the mean time. Building the library is taking a really long time.</p>
  
  <p>So is it the <code>-lboost_{libname}</code> flags that I can extend upon? Is it the <code>-I</code> flag?</p>
  
  <p>EDIT: Now that the binary location specified by <code>--prefix</code> during build is done, I tried the same thing, even with <code>-L</code> and it didn't work. Refer to my answer below for the <code>LD_LIBRARY_PATH</code> solution.</p>