[Lazarus] "Running" a library

Mark Morgan Lloyd markMLl.lazarus at telemetry.co.uk
Fri Sep 14 23:47:30 CEST 2012


Juha Manninen wrote:
> On Fri, Sep 14, 2012 at 10:34 PM, Mark Morgan Lloyd
> <markMLl.lazarus at telemetry.co.uk> wrote:
>> No, I was wondering about the extent to which a library could be defined
>> such that it was also runnable as a program.
> 
> A library cannot be run alone.
> However there 2 kinds of libraries: a dynamic library (.dll, .so) and
> a static library.
> You can test your library code by creating a program that links the
> code statically, or uses its code units directly.

I'm aware of the technology, I've been using it intermittently for 20 
years or so.

/Why/ can't a library be run standalone? We're already at the position 
that an executable can decide whether it's been invoked from a shell or 
the GUI and behave as appropriate, so why can't it decide whether it's 
being run as a program or being initialised as a library?

> Once it works well then you can make a dynamic library, but it still
> needs some extra testing.
> For example dynamic strings cannot be used across the calls,

Works here, subject to explicit use of cmem.

> GUI component usage is limited etc.

Works here as far as I've tested (i.e. merging menus from a shared 
library into the main program, using dialog(ue)s defined in the shared 
library and so on).

> For this testing you must create the "Host application" which links
> dynamically to the library.

Again, /why/?

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]




More information about the Lazarus mailing list