bcb调用bcb编译的动态库都出错,要哭了。
winxp + bcb6.0
库文件如下:我是编译的C库 ,只输出一个函数
- C/C++ code
//---------------------------------------#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 argsusedint 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文件已经加入了工程):
编译通过,连接出错。
- C/C++ code
//---------------------------------------#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)); }}
求解?
[解决办法]
你的DLL是C的,那么调用时要用:
extern "C" __declspec(dllimport) int __stdcall FucFormActive(int bFormID);
[解决办法]
需要在BCB的项目中加入输入接口库(import library),打开工程项目,使用BCB View|Project Manager打开项目列表,向项目中加入接口库(*.lib)。
做个测试通过(CB2010)
[解决办法]
祝贺lz解决问题了
"Unresolved external FucFormActive"
lz看见这些错误,提示没有找到FucFormActive
应该自己多想想,多思考