C++builder4创建及调用DLL
用C++创建DLL工程project11.Project1.h如下extern"C"__declspec(dllimport)int__stdcalltest();2.P...
用C++创建DLL工程project1
1.Project1.h如下
extern "C" __declspec(dllimport) int __stdcall test();
2.Project1.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void *)
{return 1;
}
//---------------------------------------------------------------int __stdcall test()
{
return 54;
}
然后创建一个程序调用(采用静态调用)
lib库已生成并加入
main.h如下
//---------------------------------------------------------------------------
#ifndef mainH
#define mainH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include "Project1.h"
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
////---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TLabel *Label1;
TButton *Button1;
void __fastcall Button1Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
可是在主程序中调用总说
[Linker Error] Unresolved external 'test' referenced from C:\DOCUMENTS AND SETTINGS\BI\桌面\DLL\MAIN.OBJ.
请问,哪里有问题....
只是求一个极简单调用的例子(最好有静态和动态两种) 展开
1.Project1.h如下
extern "C" __declspec(dllimport) int __stdcall test();
2.Project1.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void *)
{return 1;
}
//---------------------------------------------------------------int __stdcall test()
{
return 54;
}
然后创建一个程序调用(采用静态调用)
lib库已生成并加入
main.h如下
//---------------------------------------------------------------------------
#ifndef mainH
#define mainH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include "Project1.h"
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
////---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TLabel *Label1;
TButton *Button1;
void __fastcall Button1Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
可是在主程序中调用总说
[Linker Error] Unresolved external 'test' referenced from C:\DOCUMENTS AND SETTINGS\BI\桌面\DLL\MAIN.OBJ.
请问,哪里有问题....
只是求一个极简单调用的例子(最好有静态和动态两种) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询