Page 1 of 1

demo richview not compile delphi 12 linux platform

Posted: Sun Jan 07, 2024 9:33 am
by flyingpig
I downloaded the fmxlinux and trichviewedit demo library. An error occurs when linking a hello world project with trichview components. Without trichview library components, build and deploy occur without errors.

[DCC Error] E2597 C:\Components\TRichViewTrialDelphiFMX\TRichView\Trial\12\DelphiLinux64\12\Release\fmxRVCanvasLinuxFM.o:fmxRVCanvasLinuxFM:function Fmxrvcanvaslinuxfm::pango_font_metrics_get_height(void*): error: undefined reference to 'pango_font_metrics_get_height'
[DCC Fatal Error] F2588 Linker error code: 1 ($00000001)

[DCC Error] E2597 C:\Program Files (x86)\Embarcadero\Studio\23.0\bin\ld-linux.exe: error: cannot find -lpango-1.0
C:\Components\TRichViewTrialDelphiFMX\TRichView\Trial\12\DelphiLinux64\12\Release\fmxRVCanvasLinuxFM.o:fmxRVCanvasLinuxFM:function Fmxrvcanvaslinuxfm::pango_layout_get_context(void*): error: undefined reference to 'pango_layout_get_context'
C:\Components\TRichViewTrialDelphiFMX\TRichView\Trial\12\DelphiLinux64\12\Release\fmxRVCanvasLinuxFM.o:fmxRVCanvasLinuxFM:function Fmxrvcanvaslinuxfm::pango_context_get_metrics(void*, void*, void*): error: undefined reference to 'pango_context_get_metrics'
C:\Components\TRichViewTrialDelphiFMX\TRichView\Trial\12\DelphiLinux64\12\Release\fmxRVCanvasLinuxFM.o:fmxRVCanvasLinuxFM:function Fmxrvcanvaslinuxfm::pango_font_metrics_get_descent(void*): error: undefined reference to 'pango_font_metrics_get_descent'
C:\Components\TRichViewTrialDelphiFMX\TRichView\Trial\12\DelphiLinux64\12\Release\fmxRVCanvasLinuxFM.o:fmxRVCanvasLinuxFM:function Fmxrvcanvaslinuxfm::pango_font_metrics_get_height(void*): error: undefined reference to 'pango_font_metrics_get_height'
C:\Components\TRichViewTrialDelphiFMX\TRichView\Trial\12\DelphiLinux64\12\Release\fmxRVCanvasLinuxFM.o:fmxRVCanvasLinuxFM:function Fmxrvcanvaslinuxfm::pango_font_metrics_get_strikethrough_position(void*): error: undefined reference to 'pango_font_metrics_get_strikethrough_position'
C:\Components\TRichViewTrialDelphiFMX\TRichView\Trial\12\DelphiLinux64\12\Release\fmxRVCanvasLinuxFM.o:fmxRVCanvasLinuxFM:function Fmxrvcanvaslinuxfm::pango_font_metrics_get_strikethrough_thickness(void*): error: undefined reference to 'pango_font_metrics_get_strikethrough_thickness'
C:\Components\TRichViewTrialDelphiFMX\TRichView\Trial\12\DelphiLinux64\12\Release\fmxRVCanvasLinuxFM.o:fmxRVCanvasLinuxFM:function Fmxrvcanvaslinuxfm::pango_font_metrics_get_underline_position(void*): error: undefined reference to 'pango_font_metrics_get_underline_position'
C:\Components\TRichViewTrialDelphiFMX\TRichView\Trial\12\DelphiLinux64\12\Release\fmxRVCanvasLinuxFM.o:fmxRVCanvasLinuxFM:function Fmxrvcanvaslinuxfm::pango_font_metrics_get_underline_thickness(void*): error: undefined reference to 'pango_font_metrics_get_underline_thickness'
C:\Components\TRichViewTrialDelphiFMX\TRichView\Trial\12\DelphiLinux64\12\Release\fmxRVCanvasLinuxFM.o:fmxRVCanvasLinuxFM:function Fmxrvcanvaslinuxfm::pango_font_metrics_unref(void*): error: undefined reference to 'pango_font_metrics_unref'
[DCC Fatal Error] F2588 Linker error code: 1 ($00000001)

Re: demo richview not compile delphi 12 linux platform

Posted: Mon Jan 08, 2024 10:30 am
by Sergey Tkachenko
TRichView for Linux uses external functions from libpango-1.0.so.0, such as

Code: Select all

const
  pangolib = 'libpango-1.0.so.0';

function pango_layout_get_context(layout: PPangoLayout): PPangoContext;
  cdecl; external pangolib;
...
Pango library must be installed on the Linux computer.

Re: demo richview not compile delphi 12 linux platform

Posted: Wed Jan 10, 2024 4:33 pm
by flyingpig
what is the minimum version of the pango library required?


[DCC Error] E2597 C:\Components\TRichViewTrialDelphiFMX\TRichView\Trial\12\DelphiLinux64\12\Release\fmxRVCanvasLinuxFM.o:fmxRVCanvasLinuxFM:function Fmxrvcanvaslinuxfm::pango_font_metrics_get_height(void*): error: undefined reference to 'pango_font_metrics_get_height'

Re: demo richview not compile delphi 12 linux platform

Posted: Thu Jan 11, 2024 8:41 am
by Sergey Tkachenko
https://docs.gtk.org/Pango/method.FontM ... eight.html says that this method is available since 1.44

Re: demo richview not compile delphi 12 linux platform

Posted: Wed Feb 21, 2024 5:47 pm
by www7777
I have the same issue. Tried Ubuntu 22 and redOS, they both have pango-1.0 package installed, in both cases the library file libpango-1. 0 .so.0 exists and can be found in library or SDK folders, but cannot be load with ld for example.

Finally I came to modifying fmxRVCanvasLinuxFM.pas file for dynamic linking of the imported functions instead of the static one. Now it works fine.

Re: demo richview not compile delphi 12 linux platform

Posted: Thu Feb 22, 2024 11:24 am
by Sergey Tkachenko
www7777 wrote: Wed Feb 21, 2024 5:47 pm I have the same issue. Tried Ubuntu 22 and redOS, they both have pango-1.0 package installed, in both cases the library file libpango-1. 0 .so.0 exists and can be found in library or SDK folders, but cannot be load with ld for example.

Finally I came to modifying fmxRVCanvasLinuxFM.pas file for dynamic linking of the imported functions instead of the static one. Now it works fine.
Can you share your changes?

I do not understand how dynamic linking can help, if the required function is not available.

Re: demo richview not compile delphi 12 linux platform

Posted: Fri Feb 23, 2024 10:21 am
by www7777
ok, there are two solutions:

1. ld requires a plain .so extension of the lib, so we can just make a symlink on the target machine libpango-1.0.so to libpango-1.0.so.0, e.g.
ln -s /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0 /usr/lib/x86_64-linux-gnu/libpango-1.0.so
update SDK cache and compile the project. In my tests, once the project is compiled/linked you can remove the .so file, the project will run fine without it and will use the default so.0.

2. use dynamic linking in fmxRVCanvasLinuxFM.pas file, e.g. as follows:

interface
...
var
pango_layout_get_context:function (layout: PPangoLayout): PPangoContext; cdecl;
pango_context_get_metrics:function (context:PPangoContext; desc:PPangoFontDescription;
language:PPangoLanguage):PPangoFontMetrics; cdecl;
pango_font_metrics_get_ascent:function (metrics:PPangoFontMetrics): Integer; cdecl;
pango_font_metrics_get_descent:function(metrics:PPangoFontMetrics):Integer; cdecl;
pango_font_metrics_get_height:function(metrics:PPangoFontMetrics):Integer; cdecl;
pango_font_metrics_get_strikethrough_position:function(metrics:PPangoFontMetrics):Integer; cdecl;
pango_font_metrics_get_strikethrough_thickness:function(metrics:PPangoFontMetrics):Integer; cdecl;
pango_font_metrics_get_underline_position:function(metrics:PPangoFontMetrics):Integer; cdecl;
pango_font_metrics_get_underline_thickness:function(metrics:PPangoFontMetrics):Integer; cdecl;
pango_font_metrics_unref:procedure(metrics:PPangoFontMetrics); cdecl;
...

initialization
h := LoadLibrary(pangolib);

if h > 0 then begin
pango_layout_get_context := GetProcAddress(h, 'pango_layout_get_context');
pango_context_get_metrics := GetProcAddress(h, 'pango_context_get_metrics');
pango_font_metrics_get_ascent := GetProcAddress(h, 'pango_font_metrics_get_ascent');
pango_font_metrics_get_descent := GetProcAddress(h, 'pango_font_metrics_get_descent');
pango_font_metrics_get_height := GetProcAddress(h, 'pango_font_metrics_get_height');
pango_font_metrics_get_strikethrough_position := GetProcAddress(h, 'pango_font_metrics_get_strikethrough_position');
pango_font_metrics_get_strikethrough_thickness := GetProcAddress(h, 'pango_font_metrics_get_strikethrough_thickness');
pango_font_metrics_get_underline_position := GetProcAddress(h, 'pango_font_metrics_get_underline_position');
pango_font_metrics_get_underline_thickness := GetProcAddress(h, 'pango_font_metrics_get_underline_thickness');
pango_font_metrics_unref := GetProcAddress(h, 'pango_font_metrics_unref');

if (@pango_layout_get_context = nil) or (@pango_context_get_metrics = nil) or (@pango_font_metrics_get_ascent = nil) or
(@pango_font_metrics_get_descent = nil) or (@pango_font_metrics_get_height = nil) or (@pango_font_metrics_get_strikethrough_position = nil) or
(@pango_font_metrics_get_strikethrough_thickness = nil) or (@pango_font_metrics_get_underline_position = nil) or (@pango_font_metrics_get_underline_thickness = nil) or
(@pango_font_metrics_unref = nil) then begin
//functions not found
_exit(970);
end;
end else _exit(971); //libpango not found