Jump to content
markg

fmx.graphics in Linux .so (using Delphi 10.3)

Recommended Posts

Using Delphi 10.3, I am writing a Linux library (an .so).  I need to use some functions from fmx.graphics, but if I add it to my uses clause it does bad things although it compiles fine.  If I add it to my uses clause, without even doing anything else in code, I get the following error when I call the library (.so): "Unable to init server: Could not connect: Connection refused".

 

However, if I write a stand-alone Linux console app and add fmx.graphics, it works just fine.

 

Is this something similar to when writing a Windows dll and using vcl,graphics, you must call GdiplusStartup first to initialize the graphics subsystem?

 

If anyone has any ideas or examples, please send them my way.

Share this post


Link to post

Sorry can't help, Delphi CE here, no Linux compiler. I tried creating a DLL that uses FMX.Graphics unit. No problem in Windows 10.

Share this post


Link to post

I'm using Windows 10 also.  Did you call your dll from another program - possibly a console app?  It gives the error when it's run, not at compile time.

 

Share this post


Link to post

Yes, I can call my DLL function, no error. Library source code:

library DllWithFmx;

uses
  System.SysUtils,
  System.Classes,
  FMX.Graphics;

{$R *.res}

function TestDll: Integer; stdcall;
begin
  Result := Integer(TFontWeight.Semibold);
end;

exports
  TestDll;

begin
end.

Console app that use the DLL (the static linking is used):

program DllUse;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils;

function TestDll: Integer; stdcall; external 'DllWithFmx.dll';

var
  i: Integer;
begin
  i := TestDll;
  Writeln(i);
  Readln;
end.

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×