1

I am interested in using Firemonkey for producing an iOS app. There are several native C libraries I would like to use in this application. I know that iOS does not allow for dynamic link libraries, but is there a way to use static libraries in this firemonkey iOS app?

2
  • What does the FPC documentation have to say on the matter? Commented Apr 13, 2012 at 7:26
  • It seems that Delphi in general cannot create or use static libraries. Commented Apr 13, 2012 at 19:40

2 Answers 2

2

Yes, you can use C static libraries to link with Firemonkey iOS appli using xcode. I did it using Xcode outside RADStudio X2. With RADStudio I generated xcode project. On the mac I openned the xcode project and added :

function C_func(double :x):double; cdecl; external;

{$linklib my_c_lib.a}

I created static library project in xcode (named my_c_lib) with one C file containing :

double C_func(double x)
{
    return x+2.5;
}

I suppose that in the same manner you can use already compiled static libs.

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

1 Comment

there is a post about a similar question here
1

Here is an iOS application I made: Unit1.pas is generated by XE2:

unit Unit1;

interface

uses
  SysUtils, Types, UITypes, Classes, Variants, FMX_Types, FMX_Controls, FMX_Forms,
  FMX_Dialogs, FMXTee_Engine, FMXTee_Series, FMXTee_Procs, FMXTee_Chart,
  FMX_ExtCtrls;

type
  TForm1 = class(TForm)
    CornerButton1: TCornerButton;
    Chart1: TChart;
    Series1: TLineSeries;
    Label1: TLabel;

    procedure CornerButton1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    x : double; // I added this in Xcode Editor
  end;

// I added this declaration
function tst_function(x:double):double;cdecl;external;
var
  Form1: TForm1;


implementation

{$R *.lfm}
{$link tst1.o} // I added this

procedure TForm1.CornerButton1Click(Sender: TObject);
var      i: integer; x : double;
begin
for  i := 1  to  500  do
begin
x:=tst_function(i*3.14/250.0);
Series2.Add(x);

end

end;

end.

and the C file tst1.c is:

#include <stdio.h>
#include <math.h>

double tst_function(double x)
{
    return sin(x)+0.25;
}

Comments

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.