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
#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<iostream>
#include "dll.h"
#include <windows.h>
sum::sum()
{
 x=y=res=0;
}
sum::~sum()
{
}
void sum::input()
{
     std::cout<<"Enter two numbers ";
     std::cin>>x>>y;
}
void sum::add()
{
     res=x+y;
}
void sum::display()
{
     std::cout<<"The application in running under a dll file"<<std::endl;
     std::cout<<"The sum is "<<res<<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;
}
The host application (sample.cpp) code is
#include<iostream>
#include "dll.h"
using namespace std;
int main()
{
    sum s;
    s.input();
    s.add();
    s.display();
    system("pause");
    return 0;
}    
But i get a linker error saying:
  [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' 
I dont know what to do. I just started dll programming, but am stick with this. Can anybody help me out this?
 
     
     
     
    
` or `– Denys Séguret Nov 04 '12 at 10:56`. Please read the faq and [the markdown help](http://stackoverflow.com/editing-help) before asking again.