-2

Suppose I have a project in delphi 7 (or XE no matter) named as test.exe and another project named as pkg1.bpl(project type is Package). There is a form (like aboutbox) in the bpl project and a function to show this form. Now I compile these two projects and run test.exe. When I click on btn1, the pkg1.bpl loads and calls the function and the aboutbox form shows up. Everything is ok...!

But when I copy this test.exe and pkg1.bpl to another PC and run test.exe, there is no problem. But when I click on the btn1, an error occurs:

required package (rtl190.bpl) not found(or like this).

I want to know why delphi does not use rtl190.bpl which embedded in test.exe? or what must I do to solve this error? I want to use bpl packages for my forms in my projects, but I do not want to copy rtl190.bpl or vcl190.bpl or like these files to my customers PCs. I want to (if it is possible) embed required bpl files in ONE file as other packages can use from that.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
dph
  • 9
  • 1
  • 5
  • Is `Link with runtime packages` selected under `Project/Options/Packages/Runtime Packages`? It shouldn't be – fantaghirocco Dec 03 '15 at 10:51
  • 4
    see http://stackoverflow.com/questions/22672676/missing-bpl-files – fantaghirocco Dec 03 '15 at 10:52
  • Yes, it's possible to re-package RTL and VCL units as you like into your own packages. You can remove the automatically-added rtl.dcp from the `requires` clause of your packages. – Ondrej Kelle Dec 03 '15 at 11:13
  • When i remove rtl and vcl from requres, the bpl size grows to 4.5 MB...!!! but this is not what i want! this seems that just like the exe file it embed the vcl and rtl packages! – dph Dec 03 '15 at 11:38
  • Yes, your package now contains all the RTL code so of course the file size grows. – Ondrej Kelle Dec 03 '15 at 11:47
  • What is the actual problem that you are trying to solve? Why are you using runtime packages in the first place if executable size is a concern? – David Heffernan Dec 03 '15 at 14:24
  • so i must find other way! u know? I have a project which has about 200 forms and dialogs...! the exe size at now is about 25 MB...! I wanted to separate these forms in another packages or DLLs. but as i think now, if i split them to DLLs or Packages and as the way i wanted, every DLL or package will has more than 5 MB...! because every one has the same rtl and vcl packages!!! so i my own must think and get a new idea to get this problem solved........!!! – dph Dec 03 '15 at 15:30
  • thank you man! if you are professional in delphi programming i will be glad to connect directly to you... can you get me your EMail? – dph Dec 03 '15 at 15:33
  • What exactly is the problem? Is your actual problem that you don't like the size of the executable? In which case, packages will only lead to a larger total size. – David Heffernan Dec 03 '15 at 16:38

1 Answers1

3

I want to know why delphi does not use rtl190.bpl which embedded in test.exe?

There's no reason why it would do that. The only supported location for packages is on disk. That's a reflection of the underlying system. A package is a DLL, and DLLs must reside on disk. Any tool that loads them from memory does so using unsupported implementation details, and is liable to break in future versions of Windows.

Here are your options, as I see them:

  1. Stop using runtime packages, and compile everything into a single executable. Then you can simply copy that single executable and that's all you need to do.
  2. Continue using runtime packages, and copy the executable and all required runtime packages into the same directory.
  3. Continue using runtime packages, but embed them into your executable. Then, when the executable runs, unpack the executables onto disk, and load the packages dynamically. Dynamic loading of packages will increase the complexity of your program.
  4. Continue using runtime packages, but embed them into your executable. Then, when the executable runs, load the executables from memory using unsupported techniques, for instance with BTMemoryModule. This will increase the complexity of your program even more.

Frankly, I regard options 3 and 4 as verging on insane. Choose option 1.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Isn't it possible to build a package so that has all required packages built into it? – SilverWarior Dec 03 '15 at 16:36
  • 1
    @SilverWarior You mean, like a single executable that doesn't use runtime packages? – David Heffernan Dec 03 '15 at 16:38
  • In a way yes. What I'm wondering is this. When you are looking at some package project in `Project manager` there are four nodes in project tree. First is `Build Configuration`. Second is `Target Platforms`. Third is `Contains`. and Fourth is the `Requires` node that usually contains reference to other packages. So I'm wondering if moving some package references from `Requires` node into `Uses` node would force the compiler to build those packages right into your package? I haven't tired anything like this myself and I don't have any project to test this idea on. – SilverWarior Dec 03 '15 at 16:52
  • @DavidHeffernan, Yes. my only problem is large size of my exe file! My project is such a project that in every week has updates to many users. it is not completed yet! so this is a problem for me that transfer such a large file (event if zipped, it is about 8.MB) and this is too large for me because of low internet speeds in our country!!! – dph Dec 04 '15 at 07:31
  • My mind is like such thing that @SilverWarior said. I wanted delphi that get me a way to place required packages in one file (like DLL) and the application use this BASE file for every BPLs or DLLs which are parts of my app. and i have to place this one file in my users PC and there was not needed to transfer such things to them. if this was possible, i was not forced to build all of my app (25MB) in every updates because of a little problem in a form and send the 25MB file to my users. is this such a Unreasonable request...?! – dph Dec 04 '15 at 07:32
  • I think I answered the question that you actually asked. You are asking something else now. If you separate your program into packages then you'll need to supply RTL and VCL packages. You can't do it without them. But you only need to supply them once. You'll also enter DLL hell potentially. You'll need to ensure that you always have a matching set of packages. – David Heffernan Dec 04 '15 at 07:38
  • When you use packages, you'll ship larger executables in total because the linker can't remove unused code. There are other ways to reduce executable size, as has been asked here so many times. But this question ois not about executable size. Finally, perhaps your executable is so large because you embedded unused packages in it. – David Heffernan Dec 04 '15 at 07:40