Weird 'undefined reference' error
<p>I have run into a peculiar error in a C++ project at work.</p>

<p>I have found a fix, but I am now really satisfied, as I would like to understand what actually causes the error.</p>

<p>When building this snippet of code:</p>

<pre><code>#include &lt;iostream&gt;
#include "snmp/snmp/SW_SNMP_Values.hpp"
#include "snmp/agent/SW_Agent.hpp"
#include "snmp/agent/SW_Agent_PP.hpp"

int main()
{
    //SW_Agent_PP agent;

    return 0;
}
</code></pre>

<p>Notice that SW_Agent_PP is COMMENTED OUT!! When building this, I get a ton of undefined reference errors, for classes that are in use by the SW_Agent_PP object.</p>

<p>The FIX is to ACTUALLY CREATE THE OBJECT! so if I do this:</p>

<pre><code>#include &lt;iostream&gt;
#include "snmp/snmp/SW_SNMP_Values.hpp"
#include "snmp/agent/SW_Agent.hpp"
#include "snmp/agent/SW_Agent_PP.hpp"

int main()
{
    SW_Agent_PP agent;

    return 0;
}
</code></pre>

<p>everything works fine and dandy.</p>

<p>How can I get linker errors for NOT using something? I would like to hear if anyone have run into similar experiences before, and if they found what caused it.</p>

<p>I am sorry, but I cannot release more code as it is company property.
Many thanks in advance!</p>
