//fdb_visit.cpp
#include <fastdb.h>
#include <iostream>
#include "open_olf_cim_db_dec.h"
#include "open_olf_cim_db.h"
#include "fdb_visit.h"
using namespace std;
void fdb_visit()
{
dbCursor<BusbarSection> busbar;

int n = busbar.select();
if( n ==0 )
return;
do{
cout<<"name is "<<busbar->name<<endl;
}while( busbar.next() );

}静态库编译成功,动态库编译提示
正在链接...
fdb_visit.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: int __thiscall dbAnyCursor::select(void)" (__imp_?select@dbAnyCursor@@QAEHXZ) ,该符号在函数 "void __cdecl fdb_visit(void)" (?fdb_visit@@YAXXZ) 中被引用
fdb_visit.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: __thiscall dbAnyCursor::~dbAnyCursor(void)" (__imp_??1dbAnyCursor@@QAE@XZ) ,该符号在函数 "public: __thiscall dbCursor<class BusbarSection>::~dbCursor<class BusbarSection>(void)" (??1?$dbCursor@VBusbarSection@@@@QAE@XZ) 中被引用
fdb_visit.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) protected: __thiscall dbAnyCursor::dbAnyCursor(class dbTableDescriptor &,enum dbCursorType,unsigned char *)" (__imp_??0dbAnyCursor@@IAE@AAVdbTableDescriptor@@W4dbCursorType@@PAE@Z) ,该符号在函数 "public: __thiscall dbCursor<class BusbarSection>::dbCursor<class BusbarSection>(enum dbCursorType)" (??0?$dbCursor@VBusbarSection@@@@QAE@W4dbCursorType@@@Z) 中被引用
fdb_visit.obj : error LNK2001: 无法解析的外部符号 "public: static class dbTableDescriptor BusbarSection::dbDescriptor" (?dbDescriptor@BusbarSection@@2VdbTableDescriptor@@A)
fdb_visit.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: void __thiscall dbAnyCursor::fetch(void)" (__imp_?fetch@dbAnyCursor@@QAEXXZ) ,该符号在函数 "public: class BusbarSection * __thiscall dbCursor<class BusbarSection>::next(void)" (?next@?$dbCursor@VBusbarSection@@@@QAEPAVBusbarSection@@XZ) 中被引用
fdb_visit.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) protected: bool __thiscall dbAnyCursor::gotoNext(void)" (__imp_?gotoNext@dbAnyCursor@@IAE_NXZ) ,该符号在函数 "public: class BusbarSection * __thiscall dbCursor<class BusbarSection>::next(void)" (?next@?$dbCursor@VBusbarSection@@@@QAEPAVBusbarSection@@XZ) 中被引用
Debug/fdb_dll.dll : fatal error LNK1120: 6 个无法解析的外部命令
其中dbCursor的定义如下
template<class T>
class dbCursor : public dbAnyCursor { 
  protected:
    T record;
    
  public:
    /**
     * Cursor constructor
     * @param type cursor type (dbCursorViewOnly by default)
     */
    dbCursor(dbCursorType type = dbCursorViewOnly) 
        : dbAnyCursor(T::dbDescriptor, type, (byte*)&record) {}    /**
     * Cursor constructor with explicit specification of database.
     * This cursor should be used for unassigned tables. 
     * @param aDb database in which table lookup is performed
     * @param type cursor type (dbCursorViewOnly by default)
     */
    dbCursor(dbDatabase* aDb, dbCursorType type = dbCursorViewOnly)
        : dbAnyCursor(T::dbDescriptor, type, (byte*)&record)
    {
        db = aDb;
        dbTableDescriptor* theTable = db->lookupTable(table);
        if (theTable != NULL) { 
            table = theTable;
        }
    }

解决方案 »

  1.   

    BusbarSection是一个类,在open_olf_cim_db.h有定义和实现。
      

  2.   

    同样的程序在静态库里面编译,在exe里面调用都是正确的。
    什么地方有比较基本的关于dll的用法的资料啊?
      

  3.   

    //open_olf_cim_db.h
    class BusbarSection :public Connector{
    public:
    int8 VoltageControlZone;
    TYPE_DESCRIPTOR( (SUPERCLASS( Connector ), FIELD(VoltageControlZone) ) );
    };
    //
    #define TYPE_DESCRIPTOR(fields) \
        dbFieldDescriptor* dbDescribeComponents(dbFieldDescriptor*) { \
            return &fields; \
        } \
        static dbTableDescriptor dbDescriptor 
      

  4.   

    你的当前目录下有没有lib文件,是否导入到project中
      

  5.   

    在setting要包含.lib文件的+了么?
      

  6.   

    你没有包含lib文件.
    直接在mfc的文件视图里把lib文件添加到工程里就可以了.要看dll的详细资料,可以看window 核心编程. 详细,全面.