静态库能编译通过,但是动态库出错。
//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;
}
}
问题点数:100、回复次数:10Top
1 楼vcleaner(我没当大哥很久了.......)回复于 2004-11-02 09:58:15 得分 20
setting中包含了LIB文件了吗?Top
2 楼DentistryDoctor(不在无聊中无奈,就在沉默中变态)回复于 2004-11-02 10:00:26 得分 20
busbar?它的.lib呢?Top
3 楼ProgramInHeart(珍惜每一天!)回复于 2004-11-02 10:03:58 得分 20
沙发Top
4 楼ppfat()回复于 2004-11-02 10:06:14 得分 0
BusbarSection是一个类,在open_olf_cim_db.h有定义和实现。Top
5 楼ppfat()回复于 2004-11-02 10:07:29 得分 0
同样的程序在静态库里面编译,在exe里面调用都是正确的。
什么地方有比较基本的关于dll的用法的资料啊?Top
6 楼ppfat()回复于 2004-11-02 10:14:50 得分 0
//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
Top
7 楼ripyu(抢分的恶狼)回复于 2004-11-02 10:31:21 得分 20
头文件呢?包括了么?Top
8 楼oyljerry(【勇敢的心】→ ㊣提拉米苏√㊣)回复于 2004-11-02 10:32:31 得分 20
你的当前目录下有没有lib文件,是否导入到project中
Top
9 楼ripyu(抢分的恶狼)回复于 2004-11-02 10:32:58 得分 0
在setting要包含.lib文件的+了么?Top
10 楼yuantao(cfan)回复于 2004-11-02 11:50:09 得分 0
你没有包含lib文件.
直接在mfc的文件视图里把lib文件添加到工程里就可以了.
要看dll的详细资料,可以看window 核心编程. 详细,全面.
Top




