简体   繁体   中英

Can one build an EXE project against a BPL/DCP with “Build With Runtime Packages” unchecked, based solely on the BPLs/DCPs?

I have a BPL project (with some base stuff) and an EXE project which has in it's Search Path the location of the other project's output (BPL and DCP). When the EXE project is built with "Build With Runtime Packages", it builds fine. However, it requires me to deploy the EXE and the BPL. So far so good.

Since I'd rather deploy just the EXE (no matter it gets bigger), I'd guess that I'd just uncheck "Build With Runtime Packages" and that'd be it, but it's not the case. It won't build, and start complaining about the missing classes. The only way I can compile the EXE project is if I add the path to the actual BPL project's DCUs to the EXE project's Search Path. I can do that, but why am I forced to point to the DCUs? Can't Delphi just take them from the BPL? It's not just a matter of taste, if I go this way, and link to the DCU's, when it comes to DCUs belonging to forms, it will then ask me for the forms DFMs, forcing me to also include my sources folder to the EXE project's Search Path, and now it would seem as they are getting compiled, which is prohibitive. I can't recompile my BPL project codebase each time I want to compile my EXE project.

I hope I have made myself clear.

Any help on how to achieve what is asked in the title is appreciated.

Thank you.

There are two ways to link external libraries: static and dynamic .

When you are using runtime packages, this is a dynamic linking. Actual implementation is in the BPL file (which is a simple dll actually), methods and classes are imported from it on the process start. This reduces exe size, but requires BPL file to be shipped (same as usual dll). DCU files are not needed, because everything is already compiled and linked, linker need only to create import section.

When runtime packages are disabled, linker has to take object files for all classes and methods and combine it into the one executable. It could not extract this data from the BPL , because its is already linked executable. It would have to unlink it first, separating different modules implementation, which is basically impossible. So you have to provide DCU files, containing compiled object code to link your program.

So answer for your question title is simple - no it is not possible.

No, you can't. If you want to use runtime packages you have to turn on the compiler option to build with runtime packages.

As to the second part of your question: Building with runtime packages uses the *.dcp files to compile (the .dfm streams are linked into packages' resources so the *.dfm files are not needed directly). Building without runtime packages needs the *.dcu and *.dfm files (and any other required files).

In either case, you need to have the required files in your library/search path to be able to compile/build.

It is possible, but is very hard to implement. And you will need to create a third project for this purpose - a loader. You need to turn your original EXE project to a DLL built with runtime pckages. The loader can include your DLL project, rtl.bpl, vlc.bpl and your BPL project as resources inside loader executable. Loader will need to manually do all things that are done by LoadLibrary Windows API.

You can read more about how to load DLLs from memory and find some code samples to start with here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM