1

What are some options for creating a Delphi Class library?

I have a class TWidget that is used in multiple programs. Currently, I have each program link to \common\UnitWidget.pas source code file. However when TWidget changes, I am forced to recompile and rerelease all programs referencing it.

I am not very familiar with C#, but I believe they have a Class Library concept which allows classes to be encapsulated and shared across programs. I think this is what I am looking for in Delphi.

In Delphi I have made some DLLs, but I do not know if they can be used effectively as a class library. It seems packages are the way to go, and I should make my own package in the spirit of the RTL package. I don't know what sort of "gotchas" I'll run into, versioning, etc. However, before I go too far down the wrong rabbit hole I thought it best to humbly ask how this is approached by others.

Thanks!

3
  • 2
    Sounds like you're looking for Delphi Packages. For example: thoughtco.com/bpl-vs-dll-1058181 Commented Jul 2, 2018 at 19:07
  • 2
    Yet again downvotes without comments. What was that about stackoverflow becoming more user friendly? Commented Jul 3, 2018 at 7:38
  • @dummzeuch: while I also don't like it, people can downvote without leaving a comment. It is quite common on SO. Commented Jul 3, 2018 at 12:34

1 Answer 1

0

You must

  1. Create a runtime package for your class(es) and
  2. build your program(s) with runtime packages (plural because in that case you must use the runtime packages for the rtl and vcl/fmx that are used by your package.

Embarcadero Dokwiki on runtime packages

Sign up to request clarification or add additional context in comments.

2 Comments

This is a pain because you then have to deploy lots of runtime bpls instead of just one exe. What would be nice would be an equivalent of a C/C++ lib file?
A C lib file is a collection of .obj files, as far as I understand it. The Delphi equivalent would be a collection of dcu files (a dcu file is the compiled version of a unit), but as far as I know, such a thing does not exist. You can of course provide the dcu files of all units that contain your source code. Note though, that dcu files are version specific (dcu files from Delphi N can not be used in Delphi N+1 and vice versa) and also depend on compiler settings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.