1

Possible Duplicate:
What is an undefined reference/unresolved external symbol error and how do I fix it?

I have a LNK error that involves a class A and its derived class B. More precisely, I have this compilation error

Error   239 error LNK2019: unresolved external symbol "public: virtual __thiscall A::~A(void)" (??1A@@UAE@XZ) referenced in function "public: virtual __thiscall B::~B(void)" (??1B@@UAE@XZ)    D:\Products\path\file.lib(B.obj)
Error   240 error LNK2019: unresolved external symbol "public: __thiscall A::A(void)" (??A@@QAE@XZ) referenced in function "public: __thiscall B::B(void)" (??B@@QAE@XZ)    D:\Products\path\file.lib(B.obj)
Error   241 error LNK2019: unresolved external symbol "public: void __thiscall A::function(float * *,float * *,float * *,float * *,int)" (?function@A@@QAEXPAPAM000H@Z) referenced in function "public: class SomeType* __thiscall B::function_bis(void)" (?function_bis@B@@QAEPAVSomeType@@XZ) D:\Products\path\file.lib(B.obj)

I guess this may be related to, say, call of inherited constructor, or the non-respect of the signature in some call of function() or function_bis(). However, such mistakes i cannot find.

Do you have a hint to a possible way to solve ? Here is code for (simplified) A and B.

B.cpp

B::B(void)
{
}

B::B(Type1* d1, Type1* d2, Type1* r):A()
{
    D1= d1;
    D2= d2;
    R= r;
}


B::~B( void )
{
}

SomeType* B::function()
{
     // do things
     function_bis() ;
}

B.h

class B:
    public A
{
public:

    B(void) ;
    B(Type1* , Type1* , Type1* );
    virtual ~B(void);

    SomeType* function() ;

private:

    Type1* D1;
    Type1* D2;
    Type1* R;

};

A.cpp

using namespace std ;

A::A(void){}

A::~A(void){}

void A::function_bis(float** d, float** d2, float** d3, float** d4, int n)
{}

A.h

class A
{

public:
    A(void);
    virtual ~A(void);

    void function_bis(float** , float** , float** , float** , int );

};

Thanks!

Community
  • 1
  • 1
kiriloff
  • 25,609
  • 37
  • 148
  • 229

1 Answers1

2

Everything looks legit in your code.

My guess is that you actually don't compile A.cpp or somehow you don't include the resulting object file in your linking step (you miss A::A, A::~A and A::function_bis which are defined in A.cpp).

Qortex
  • 7,087
  • 3
  • 42
  • 59
  • A is in a separate lib. lib containing A compiles all right. solution containing B does not compile. it compiles, however, two hours earlier. – kiriloff Nov 27 '12 at 15:39
  • trying to recompile project and rebuild solution – kiriloff Nov 27 '12 at 15:41
  • Makes sense then. Check that A.lib is correctly included by the linker, and that it's compiled with the same compiler options (the issue could be different name mangling). Do you properly DLL_EXPORT the class A? – Qortex Nov 27 '12 at 16:00