Dll programming in C++
<p>Hi I am trying to run an application using dll. I am using Dev C++, but i always get a linker error.
The code of dll.h is</p>

<pre><code>#ifndef _DLL_H_
#define _DLL_H_

#if BUILDING_DLL
#define DLLIMPORT __declspec (dllexport)
#else 
#define DLLIMPORT __declspec (dllimport)
#endif 


class DLLIMPORT sum
{
  public:
    sum();
    void input();
    void add();
    void display();
    virtual ~sum(void);

  private:
          int x,y,res;

};


#endif 

and that of dllmain.cpp is
#include&lt;iostream&gt;
#include "dll.h"
#include &lt;windows.h&gt;
sum::sum()
{
 x=y=res=0;
}


sum::~sum()
{
}
void sum::input()
{
     std::cout&lt;&lt;"Enter two numbers ";
     std::cin&gt;&gt;x&gt;&gt;y;
}
void sum::add()
{
     res=x+y;
}
void sum::display()
{
     std::cout&lt;&lt;"The application in running under a dll file"&lt;&lt;std::endl;
     std::cout&lt;&lt;"The sum is "&lt;&lt;res&lt;&lt;std::endl;
}              

BOOL APIENTRY DllMain (HINSTANCE hInst     /* Library instance handle. */ ,
                       DWORD reason        /* Reason this function is being called. */ ,
                       LPVOID reserved     /* Not used. */ )
{
    switch (reason)
    {
      case DLL_PROCESS_ATTACH:
        break;

      case DLL_PROCESS_DETACH:
        break;

      case DLL_THREAD_ATTACH:
        break;

      case DLL_THREAD_DETACH:
        break;
    }

    /* Returns TRUE on success, FALSE on failure */
    return TRUE;
}
</code></pre>

<p>The host application (sample.cpp) code is</p>

<pre><code>#include&lt;iostream&gt;
#include "dll.h"
using namespace std;
int main()
{
    sum s;
    s.input();
    s.add();
    s.display();
    system("pause");
    return 0;
}    
</code></pre>

<p>But i get a linker error saying:</p>

<pre><code>  [Linker error] undefined reference to `_imp___ZN3sumC1Ev@4' 
  [Linker error] undefined reference to `_imp___ZN3sum5inputEv@4' 
  [Linker error] undefined reference to `_imp___ZN3sum3addEv@4' 
  [Linker error] undefined reference to `_imp___ZN3sum7displayEv@4' 
  [Linker error] undefined reference to `_imp___ZN3sum7displayEv@4' 
  [Linker error] undefined reference to `_imp___ZN3sum7displayEv@4' 
  [Linker error] undefined reference to `_imp___ZN3sum7displayEv@4' 
</code></pre>

<p>I dont know what to do. I just started dll programming, but am stick with this.
Can anybody help me out this?</p>
