<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">I've got a static FPC library on iOS
that works fine. Don't pass strings back and forth, pass PChar's.
Pointer-to-records are OK, too, but I'd think twice regarding
objects.<br>
<br>
<br>
On 8/26/2014 4:47 PM, Sergio Flores wrote:<br>
</div>
<blockquote
cite="mid:CADRVyE0ijcJJAVca0N32-h6nVS89083OAP_cNJujxTPkydWkMw@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>Let's start this email by saying that I know
perfectly that FPC does not support static
libraries, I read all I could find about it.<br>
</div>
However most reasons talk about that there would be
problems if someone tried to use two fpc static libs
together because of duplicated symbols. <br>
<br>
In my case I want to create a iPhone static lib to be
used by objective-c and C++ users. Since in this
special case there will be one and only one lib
written in pascal, I though this would make it
possible.<br>
<br>
</div>
<div>I saw that my own iOS projects that were based on
templates worked by compiling a static libFPC.a that
would be then called by Objective-C.<br>
<br>
</div>
So I did create my own static library by gathering all
.o files from FPC into a .a file. I wrote a .h header
and added the static lib into a Xcode Objective-C
project.<br>
</div>
Ok, it compiles and links correctly. It calls some of the
pascal functions correctly. But.. then it later crashes in
one of the pascal functions. <br>
<br>
</div>
Note that I have a lib_init() function called from C that is
used to initialize the pascal library, and it calls this
undocumented fpc function:<br>
<br>
procedure internal_initializeunits(); external name
'FPC_INITIALIZEUNITS';<br>
<br>
</div>
This function from what I understood it calls all units
initialization sections, right?<br>
Still, I'm missing something... the libFPC.a compiled in xcode
templates works fine with Objective-C, but also it does not
share any memory back or forward.<br>
<br>
</div>
This seems to be some problem with memory allocation, since only
calling any function that creates pascal strings or classes seem
to crash the app. Any clue?<br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
fpc-devel maillist - <a class="moz-txt-link-abbreviated" href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel</a>
</pre>
</blockquote>
<br>
</body>
</html>