1

重複の可能性:
未定義の参照/未解決の外部シンボル エラーとは何ですか? また、どのように修正すればよいですか?

クラス A とその派生クラス B に関連するLNKエラーが発生しました。より正確には、このコンパイル エラーが発生しました。

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)

これは、たとえば、継承されたコンストラクターの呼び出し、または function() または function_bis() の呼び出しでの署名の非尊重に関連している可能性があると思います。しかし、そのような間違いを見つけることはできません。

を解決するためのヒントはありますか? (簡略化された)Aと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 );

};

ありがとう!

4

1 に答える 1

2

コードではすべてが合法に見えます。

私の推測では、実際にはA.cppをコンパイルしていないか、リンクステップに結果のオブジェクトファイルを含めていません(で定義されているA :: A、A ::〜A、およびA::function_bisを見逃していますA.cpp)。

于 2012-11-27T15:34:15.067 に答える