怎么把单EXE工程文件拆成EXE+BPL方式的?

wg961423 2012-03-31 04:13:26
目前已经有一个单EXE的工程,编译好的EXE有9M,主要是编译太慢了

想把工程拆成EXE+BPL的方式,这样就不用每次都全部重新编译了,只要编译修改过的BPL就行了,但不知道怎么改,网上查到的都是Delphi的,没找到BCB的。

谁能给个BCB的小例子(最好是BPL中包含Form及Frame的)?
...全文
277 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
wg961423 2012-05-14
  • 打赏
  • 举报
回复
很感谢PPower,加入VCL.bpi就OK了。

结贴了
勉励前行 2012-05-13
  • 打赏
  • 举报
回复
你现在是BPL编译出问题,还是EXE出问题?

1.EXE是编译成单独的EXE 还是动态加载的BPL,还是带BPL包运行的EXE
2.分拆后,EXE要指定连接对应的 BPL , 否则 LINK时会失败.
3.分拆成多个BPL包后,每个包里含哪些单元,必须要规划,因为不允许多个包同时含有两个相同的单元
4.无论是分包或是DLL, 程序分层都是要考虑的问题,只分模块不分层是容易出乱子的.

void __fastcall PACKAGE Register()
{
// Make sure that, as part of the startup
// code, the streaming classes are registered
// with the streaming system.
#pragma startup Register
Classes::RegisterClass(__classid(TMyForm));
}
#pragma startup Register //只是指定加载包时要运行的函数,一般为初始化代码.这行可以放在函数外.
Classes::RegisterClass(__classid(TMyForm));//应该是加了这个后才出的 Link Error .

这个link error,一般的解决方法是在需求包中加入对应的 bpi .对于不同的版本,其包名称略有差别,这也是 BPL方式烦人的一点:你需要找出不同的单元是放在哪个BPL中. 你可以试着加 vcl.bpi

wg961423 2012-05-10
  • 打赏
  • 举报
回复
再顶一下
wg961423 2012-05-08
  • 打赏
  • 举报
回复
BPL或DLL都可以的,不过感觉BPL更适合一些。
CCED136 2012-05-03
  • 打赏
  • 举报
回复
或者采用 静态链接库, 工程修改为 EXE + LIB 形式, 编译更快(基本上仅编译 EXE 部分),连接快一些。
CCED136 2012-05-03
  • 打赏
  • 举报
回复
最好还是拆分成 exe + DLL 的形式哦, BPL 不适合楼主的意图
wg961423 2012-04-05
  • 打赏
  • 举报
回复


#ifndef Unit3H
#define Unit3H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TMyForm : public TForm
{
typedef TForm inherited;
__published: // IDE-managed Components
private: // User declarations
public: // User declarations
__fastcall TMyForm(TComponent* Owner);
void __fastcall ShowStr(AnsiString Str);
};
//---------------------------------------------------------------------------
extern PACKAGE TMyForm *MyForm;
//---------------------------------------------------------------------------
#endif




#include <vcl.h>
#pragma hdrstop

#include "Unit3.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TMyForm *MyForm;
//---------------------------------------------------------------------------
__fastcall TMyForm::TMyForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TMyForm::ShowStr(AnsiString Str)
{
ShowMessage(Str);
}
//---------------------------------------------------------------------------
void __fastcall PACKAGE Register()
{
// Make sure that, as part of the startup
// code, the streaming classes are registered
// with the streaming system.
#pragma startup Register
Classes::RegisterClass(__classid(TMyForm));
}
//---------------------------------------------------------------------------
wg961423 2012-04-05
  • 打赏
  • 举报
回复

//Unit3.h

#ifndef Unit3H
#define Unit3H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TMyForm : public TForm
{
typedef TForm inherited;
__published: // IDE-managed Components
private: // User declarations
public: // User declarations
__fastcall TMyForm(TComponent* Owner);
void __fastcall ShowStr(AnsiString Str);
};
//---------------------------------------------------------------------------
extern PACKAGE TMyForm *MyForm;
//---------------------------------------------------------------------------
#endif


//Unit3.cpp

#include <vcl.h>
#pragma hdrstop

#include "Unit3.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TMyForm *MyForm;
//---------------------------------------------------------------------------
__fastcall TMyForm::TMyForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TMyForm::ShowStr(AnsiString Str)
{
ShowMessage(Str);
}
//---------------------------------------------------------------------------
void __fastcall PACKAGE Register()
{
// Make sure that, as part of the startup
// code, the streaming classes are registered
// with the streaming system.
#pragma startup Register
Classes::RegisterClass(__classid(TMyForm));
}
//---------------------------------------------------------------------------
wg961423 2012-04-05
  • 打赏
  • 举报
回复
在BPL的工程里的啊
缘中人 2012-04-05
  • 打赏
  • 举报
回复
TMyForm添加到工程里
wg961423 2012-04-05
  • 打赏
  • 举报
回复

void __fastcall PACKAGE Register()
{
// Make sure that, as part of the startup
// code, the streaming classes are registered
// with the streaming system.
#pragma startup Register
Classes::RegisterClass(__classid(TMyForm));
}


按网上说的,在BPL里加上这个后,编译一直报:
[ILINK32 Error] Error: Unresolved external '__tpdsc__ Forms::TForm' referenced from E:\BCB\CS67_EXEBPL\BPL\DEBUG\UNIT3.OBJ
[ILINK32 Error] Error: Unresolved external 'Forms::TForm::' referenced from E:\BCB\CS67_EXEBPL\BPL\DEBUG\UNIT3.OBJ
[ILINK32 Error] Error: Unresolved external '__fastcall Forms::TCustomForm::AfterConstruction()' referenced from E:\BCB\CS67_EXEBPL\BPL\DEBUG\UNIT3.OBJ
[ILINK32 Error] Error: Unresolved external '__fastcall Forms::TCustomForm::BeforeDestruction()' referenced from E:\BCB\CS67_EXEBPL\BPL\DEBUG\UNIT3.OBJ
等错误啊!

这个是什么原因啊?
wg961423 2012-04-01
  • 打赏
  • 举报
回复
问题是不懂啊
缘中人 2012-03-31
  • 打赏
  • 举报
回复
懂得bpl封装原理就可以了

13,825

社区成员

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

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