我在程序中引用一个DLL,从该DLL的头文件可以看出其中包含3个类A,B,C.其中类B,类C都继承个类A,我在使用的时候可以new类A,但new类B,类C时出现link错误。请问是什么原因?

解决方案 »

  1.   

    可能是BC的实现体没有在DLL中
      

  2.   

    不能吧,这个dll是别的公司作好了的,现在公司让我调查我调用的问题
      

  3.   

    是的,确定,lib和dll是放在vc98的bin和lib的目录下的,作为内部调用的
      

  4.   

    而且我能new KD_KmfLib(),而new KD_KmfEncoder(),new KD_KmfEncoder()的时候都出现link错误呢
      

  5.   

    打错了,sorry
    而且我能new A(),而new B(),new C()的时候都出现link错误呢
      

  6.   

    把你包含的.h贴出来看一下
    导入DLL中的类
    class __declspec(dllimport) A
    {
     A的成员;
    }
      

  7.   

    我怀疑class B和class C没有__declspec(dllimport)
      

  8.   

    .h文件如下
    #ifndef __KMFCODEC_H
    #define __KMFCODEC_H#include <time.h>class KD_KmfLib
    {
    public:
    typedef struct _VAL_DATA
    {
    int size; //&#44578;??&#46192;?&#44566;&#44541;&#44571;(byte)
    void *data;
    } VAL_DATA;
    typedef struct _KMF_INFO
    {
    char *version;

    char *url; /
    } KMF_INFO; //-------------------------
    // &#44566;&#44590;&#47427;&#48810;?&#47806;&#47852;
    typedef struct _PHRASE_INFO
    {
    char *name;
    int  start;
    } PHRASE_INFO;
    typedef struct _T3G_INFO
    {
    unsigned frequency;


    unsigned channel; PHRASE_INFO phrase_data[3];  } T3G_INFO;};class _KmfEncoder;
    class _KmfDecoder;
    class KD_KmfEncoder : public KD_KmfLib
    {public:

    KD_KmfEncoder(); // &#44578;&#44570;&#44579;&#44619;&#44559;?
    ~KD_KmfEncoder();
    bool SetKmfInfo( const KMF_INFO & kmf_info );
    private:
    _KmfEncoder *context;
    };class KD_KmfDecoder : public KD_KmfLib
    {
    public:

    enum EN_FORMAT 
    {
    FORMAT_ILLEGAL, 
    FORMAT_3G2    
    };

    typedef struct _DECODE_INFO 
    {
    unsigned frame_no;
    unsigned sample_offset;
    unsigned sample_count;

    } DECODE_INFO;
    KD_KmfDecoder(); ~KD_KmfDecoder();
    bool GetT3gData( VAL_DATA & t3g_data ); //t3g(3g2)&#44578;??(OUT)private:
    _KmfDecoder *context;
    };#endif // __KMFCODEC_H
      

  9.   

    但现在头文件改在B,C类的定义前都加了__declspec(dllimport),也重新生成了.lib文件,但还是不行,急呀
      

  10.   

    你的类的DLL里面的类定义需要使用__declspec(dllexport)引入的时候,需要定义为__declspec(dllimport)