title: Including boost libraries in make files
body: <p>I'm learning Boost and am having trouble with my makes files.
  Here is my basic makefile:</p>
  
  <pre><code>accesstimer: acctime.o btimer.o
      g++ acctime.o btimer.o -o accesstimer
  
  acctime.o: acctime.cpp btimer.h
      g++ -c acctime.cpp 
  
  bentimer.o: btimer.cpp btimer.h
      g++ -c btimer.cpp 
  </code></pre>
  
  <p>When acctime.cpp has no boost filesystem elements in it this m,ake file works fine.
  As soon as I add boost filesystem elements I obviously need to make references to the boost libray in the make file this is where I am having issues.</p>
  
  <p>The following line works for a single file compilation:</p>
  
  <pre><code>g++ -I /usr/local/boost/boost_1_39_0 boosttest1.cpp -o bt1 /usr/local/boost/boost_1_39_0/stage/lib/libboost_filesystem-gcc41-mt.a /usr/local/boost/boost_1_39_0/stage/lib/libboost_system-gcc41-mt.a
  </code></pre>
  
  <p>Now I'm trying to integrate this into the make file. I've tried many based on what information I can find on the web but none are working this is my latest:</p>
  
  <pre><code>accesstimer: acctime.o bentimer.o
      g++ acctime.o bentimer.o -o accesstimer
  
  acctime.o: acctime.cpp bentimer.h
      g++ -c -I /usr/local/boost/boost_1_39_0 acctime.cpp /usr/local/boost/boost_1_39_0/stage/lib/libboost_filesystem-gcc41-mt.a /usr/local/boost/boost_1_39_0/stage/lib/libboost_system-gcc41-mt.a
  
  bentimer.o: bentimer.cpp bentimer.h
      g++ -c bentimer.cpp 
  </code></pre>
  
  <p>Unfortunately it stlill can't find the Boost libraries, can anyone help?
  thanks</p>
  
  <p>Having read the advice of the people who've answered I've now got this:</p>
  
  <pre><code>accesstimer: acctime.o bentimer.o
      g++ -L /usr/local/boost/boost_1_39_0 acctime.o /usr/local/boost/boost_1_39_0/stage/lib/libboost_filesystem-gcc41-mt.a /usr/local/boost/boost_1_39_0/stage/lib/libboost_system-gcc41-mt.a bentimer.o -o accesstimer
  
  acctime.o: acctime.cpp bentimer.h
      g++ -c acctime.cpp 
  
  bentimer.o: bentimer.cpp bentimer.h
      g++ -c bentimer.cpp 
  </code></pre>
  
  <p>But this still fails to link.</p>
  
  <p>This is the error message I'm getting:</p>
  
  <pre><code>g++ -L /usr/local/boost/boost_1_39_0/stage/lib/libboost_filesystem-gcc41-mt.a /usr/local/boost/boost_1_39_0/stage/lib/libboost_system-gcc41-mt.a acctime.o  bentimer.o -o accesstimer
  acctime.o: In function boost::enable_if&lt;boost::filesystem::is_basic_path&lt;boost::filesystem::basic_path&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, boost::filesystem::path_traits&gt; &gt;, bool&gt;::type boost::filesystem::exists&lt;boost::filesystem::basic_path&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, boost::filesystem::path_traits&gt; &gt;(boost::filesystem::basic_path&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, boost::filesystem::path_traits&gt; const&amp;)':
  acctime.cpp:(.text._ZN5boost10filesystem6existsINS0_10basic_pathISsNS0_11path_traitsEEEEENS_9enable_ifINS0_13is_basic_pathIT_EEbE4typeERKS7_[boost::enable_if&lt;boost::filesystem::is_basic_path&lt;boost::filesystem::basic_path&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, boost::filesystem::path_traits&gt; &gt;, bool&gt;::type boost::filesystem::exists&lt;boost::filesystem::basic_path&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, boost::filesystem::path_traits&gt; &gt;(boost::filesystem::basic_path&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, boost::filesystem::path_traits&gt; const&amp;)]+0x26): undefined reference to `boost::filesystem::detail::status_api(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, int&amp;)'
  collect2: ld returned 1 exit status
  make: *** [accesstimer] Error 1
  </code></pre>
  
  <p>Following orsogufo's advice (thanks! much appreciated) now have this:</p>
  
  <pre><code>accesstimer: acctime.o bentimer.o
      g++ -L/usr/local/boost/boost_1_39_0/stage/lib -llibboost_filesystem-gcc41-mt.a -llibboost_system-gcc41-mt.a acctime.o bentimer.o -o accesstimer  
  
  acctime.o: acctime.cpp bentimer.h
      g++ -c acctime.cpp 
  
  bentimer.o: bentimer.cpp bentimer.h
      g++ -c bentimer.cpp 
  </code></pre>
  
  <p>Looking better, but still can't quite find the library:</p>
  
  <pre><code>g++ -L/usr/local/boost/boost_1_39_0/stage/lib -llibboost_filesystem-gcc41-mt.a -llibboost_system-gcc41-mt.a acctime.o bentimer.o -o accesstimer
  /usr/bin/ld: cannot find -llibboost_filesystem-gcc41-mt.a
  collect2: ld returned 1 exit status
  make: *** [accesstimer] Error 1
  </code></pre>
  
  <p>I've double checked that location and the library is definately at:
  /usr/local/boost/boost_1_39_0/stage/lib/libboost_filesystem-gcc41-mt.a </p>
  
  <p>STill no joy, usimg this now:</p>
  
  <pre><code>accesstimer: acctime.o bentimer.o
      g++  -L/usr/local/boost/boost_1_39_0 -lboost_filesystem-gcc41-mt acctime.o bentimer.o -o accesstimer    
  
  acctime.o: acctime.cpp bentimer.h
      g++ -I /usr/local/boost/boost_1_39_0 -c acctime.cpp 
  
  bentimer.o: bentimer.cpp bentimer.h
      g++ -c bentimer.cpp 
  </code></pre>
  
  <p>Getting:</p>
  
  <pre><code>g++  -L/usr/local/boost/boost_1_39_0/stage/lib/ -llibboost_filesystem-gcc41-mt acctime.o bentimer.o -o accesstimer
  /usr/bin/ld: cannot find -llibboost_filesystem-gcc41-mt
  collect2: ld returned 1 exit status
  make: *** [accesstimer] Error 1
  </code></pre>
  
  <p>It's working with this:</p>
  
  <pre><code>accesstimer: acctime.o bentimer.o
      g++ -L/usr/local/boost/boost_1_39_0/stage/lib -lboost_filesystem acctime.o bentimer.o -o accesstimer    
  
  acctime.o: acctime.cpp bentimer.h
      g++ -I /usr/local/boost/boost_1_39_0 -c acctime.cpp 
  
  bentimer.o: bentimer.cpp bentimer.h
      g++ -c bentimer.cpp 
  </code></pre>
  
  <p>Thanks for all your help</p>