[Lazarus] Shared libraries, cmem and heaptrc

Mark Morgan Lloyd markMLl.lazarus at telemetry.co.uk
Fri Jun 8 14:48:39 CEST 2012

Mattias Gaertner wrote:
> On Fri, 08 Jun 2012 09:15:46 +0000
> Mark Morgan Lloyd <markMLl.lazarus at telemetry.co.uk> wrote:
>> Before cautiously tackling a shared library, I thought I'd have a trial 
>> run with cmem in the program that's going to call it. I find that if I 
>> put 'cmem, heaptrc' at the start of the .lpr it runs and I get heaptrc 
>> output, /but/ one of the files has a wildly erroneous error number.

Should read "wildly erroneous line number".

>> If I remove both cmem and heaptrc from the .lpr  I still get the error, 
>> despite having carefully removed all binaries etc. Is there a cache 
>> somewhere that also needs to be cleared?
> AFAIK cmem and heaptrc only change the program and not any other unit
> ppu/o.
> But you can use Run / Clean up build files to make sure.

I did do, and checked for old files in the project directories. I'm 
definitely running the right binary, since I don't get heaptrc output if 
I disable it in the IDE options. I get the error whether or not I'm 
using cmem. Laz 1.1, FPC 2.6.0, Linux, GTK2, all CG range checks etc. 

> How do you share the shared units between library and program?

I haven't got that far yet, I'm trying to tackle it one stage at a time. 
But my plan is to use a class which wraps and opens the shared library 
on first use, that contains methods which are exact analogues of 
exported entry points (and can be described by a .inc file shared 
between the two projects).

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