bcb调用bcb编译的动态库都出错,要哭了。

失落的羊 2010-03-17 10:36:40
winxp + bcb6.0

库文件如下:我是编译的C库 ,只输出一个函数

//---------------------------------------------------------------------------

#include <windows.h>
//---------------------------------------------------------------------------
// Important note about DLL memory management when your DLL uses the
// static version of the RunTime Library:
//
// If your DLL exports any functions that pass String objects (or structs/
// classes containing nested Strings) as parameter or function results,
// you will need to add the library MEMMGR.LIB to both the DLL project and
// any other projects that use the DLL. You will also need to use MEMMGR.LIB
// if any other projects which use the DLL will be performing new or delete
// operations on any non-TObject-derived classes which are exported from the
// DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling
// EXE's to use the BORLNDMM.DLL as their memory manager. In these cases,
// the file BORLNDMM.DLL should be deployed along with your DLL.
//
// To avoid using BORLNDMM.DLL, pass string information using "char *" or
// ShortString parameters.
//
// If your DLL uses the dynamic version of the RTL, you do not need to
// explicitly add MEMMGR.LIB as this will be done implicitly for you
//---------------------------------------------------------------------------

#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
//---------------------------------------------------------------------------


extern __declspec(dllexport)
int __stdcall FucFormActive(int bFormID);

int __stdcall FucFormActive(int bFormID)
{
return bFormID+300;

}



然后在应用程序中,如下静态调用(前面生成的bc.lib文件已经加入了工程):
编译通过,连接出错。

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
__declspec(dllimport) int __stdcall FucFormActive(int bFormID);
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------


void __fastcall TForm1::Button1Click(TObject *Sender)
{
//
int cc=FucFormActive(20);

ShowMessage("It is"+IntToStr(cc));

}

}


求解?
...全文
135 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
周药师 2010-03-18
  • 打赏
  • 举报
回复
祝贺lz解决问题了

"Unresolved external FucFormActive"
lz看见这些错误,提示没有找到FucFormActive
应该自己多想想,多思考
mabaoyes 2010-03-18
  • 打赏
  • 举报
回复
keiy 正解。加上就可以.
恭喜楼主搞定问题!
失落的羊 2010-03-17
  • 打赏
  • 举报
回复
谢谢楼上的几位。keiy 正解。加上就可以了。
ydlchina 2010-03-17
  • 打赏
  • 举报
回复
需要在BCB的项目中加入输入接口库(import library),打开工程项目,使用BCB View|Project Manager打开项目列表,向项目中加入接口库(*.lib)。

做个测试通过(CB2010)
柯本 2010-03-17
  • 打赏
  • 举报
回复
你的DLL是C的,那么调用时要用:
extern "C" __declspec(dllimport) int __stdcall FucFormActive(int bFormID);
失落的羊 2010-03-17
  • 打赏
  • 举报
回复
链接错误如下:
[Linker Error] Unresolved external '__stdcall FucFormActive(int)' referenced from F:\TMPWORKSHOP\BCB_DLL\USE_DLL\UNIT1.OBJ
失落的羊 2010-03-17
  • 打赏
  • 举报
回复
顺便说一下,我用生成的bc.dll,动态调用,程序是正常的。

13,870

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧