How can I use external libraries in C++?
<p>I just started learning C++(coming from Java &amp; Python) and am trying to learn how to use other libraries.  I found some sample code(from the boost site) I wanted to run(below) but its giving me this error:</p>

<pre><code>`Undefined symbols for architecture x86_64:
  "boost::gregorian::greg_month::get_month_map_ptr()", referenced from:
      unsigned short boost::date_time::month_str_to_ushort&lt;boost::gregorian::greg_month&gt;(std::string const&amp;) 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)`
</code></pre>

<p>I think the code is solid(since its not produced by me :-) but I’m not sure the steps required to use another library. So far, I just added the #include but should I also be using a header file for this(I know how to use one when I create multiple files when I create them myself but unsure about external libraries).</p>

<p>I found a similar question ( <a href="http://stackoverflow.com/questions/7223809/using-from-string-with-boost-date">using from_string with boost date</a> ), that suggested I need to link it boost’s datatime, so I ran the command(changed filenames) and got this error:</p>

<pre><code>`ld: library not found for -lboost_date_time
collect2: ld returned 1 exit status`
</code></pre>

<p>I think I installed boost correctly, I used <code>Brew</code> on the mac and saw it compile a bunch of files(it took like an hour to install).  So if it is installed, What am I doing wrong(or not doing)?</p>

<p>Thanks</p>

<p>Here’s the code:</p>

<pre><code>#include "boost/date_time/gregorian/gregorian.hpp"
#include &lt;iostream&gt;

int
main() 
{

    using namespace boost::gregorian;
    std::string s;
    std::cout &lt;&lt; "Enter birth day YYYY-MM-DD (eg: 2002-02-01): ";
    std::cin &gt;&gt; s;
    try {
        date birthday(from_simple_string(s));
        date today = day_clock::local_day();
        days days_alive = today - birthday;
        days one_day(1);
        if (days_alive == one_day) {
            std::cout &lt;&lt; "Born yesterday, very funny" &lt;&lt; std::endl;
        }
        else if (days_alive &lt; days(0)) {
            std::cout &lt;&lt; "Not born yet, hmm: " &lt;&lt; days_alive.days() 
            &lt;&lt; " days" &lt;&lt;std::endl;
        }
        else {
            std::cout &lt;&lt; "Days alive: " &lt;&lt; days_alive.days() &lt;&lt; std::endl;
        }

    }
    catch(...) {
        std::cout &lt;&lt; "Bad date entered: " &lt;&lt; s &lt;&lt; std::endl;
    }
    return 0;
}
</code></pre>
