Jump to content
Soulflesh

Unable to compile P4D with Delphi 10.4 for Linux64

Recommended Posts

Hi,

 

unfortunately it's not possible to compile PythonEngine.pas for Linux64 with Delphi 10.4.

 

[DCC Fehler] PythonEngine.pas(198): E2003 Undeklarierter Bezeichner: 'PUCSChar'
[DCC Fehler] PythonEngine.pas(199): E2007 Konstante oder Typenbezeichner erwartet
[DCC Fehler] PythonEngine.pas(4396): E2010 Inkompatible Typen: 'Dynamic array' und 'UCS4String'

 

Any ideas?

Best regards

Edited by Soulflesh

Share this post


Link to post

There was a typo which is not fixed

 

{$IFDEF POSIX}
  PWCharT = PUCS4Char;
  PPWCharT = PUCS4Char^;
  WCharTString = UCS4String;
{$ELSE}

Please try again with the latest.  Please report back any further issues, since I have not tested with Linux recently.

Edited by pyscripter

Share this post


Link to post

Hi pyscripter,

 

Thank you. I have additionally changed the following lines and now I'm able to compile:

 

199 --> PPWCharT = ^PUCS4Char;

4396 --> WL := UnicodeStringToUCS4String(TempS);

 

Best regards

Share this post


Link to post
36 minutes ago, Soulflesh said:

4396 --> WL := UnicodeStringToUCS4String(TempS);

Do you mean?

    WL[Ι] := UnicodeStringToUCS4String(TempS);

 

Changes committed.

Share this post


Link to post

Unfortunately now I get a "range check" exception here:

 

[PythonEngine.pas / Line 4219]

if Assigned(Py_SetProgramName) and (ProgramName <> '') then
    Py_SetProgramName(PWCharT(FProgramName));

 

My "configuration" is:

PythonEngine.UseLastKnownVersion := false;
PythonEngine.DllPath := '/usr/lib/x86_64-linux-gnu';
PythonEngine.DllName := 'libpython3.9.so.1.0';

 

Any ideas?

Best regards

Share this post


Link to post

The exception is raised in the UCS4StringToUnicodeString function.

Called by function  TPythonEngine.GetProgramName: UnicodeString;

And FProgramName is "{...}" ??!

Share this post


Link to post

FProgramName should have a lenght of 0 (empty string) unless you call SetProgramName.

Could you please check whether UCS4StringToUnicodeString fails with an empty string?

UCS4String is defined as an array of UCS4Char.

 

Could this be a fix?


 

function  TPythonEngine.GetProgramName: UnicodeString;
begin
{$IFDEF POSIX}
  if Length(FProgramName) = 0 then
    Result := ''
  else
    Result := UCS4StringToUnicodeString(FProgramName);
{$ELSE}
  Result := FProgramName;
{$ENDIF}
end;

 

Edited by pyscripter

Share this post


Link to post

This raises an exception:

SetLength(Test,0);
Result := UCS4StringToUnicodeString(Test);

Your suggested code has solved the problem! 😀

Python Scripts runs now on Linux (Ubuntu 18.04.5 LTS with Python 3.9.6).

 

Best regards

  • Like 1

Share this post


Link to post

Hi pyscripter,

 

Unfortunately a wrong character has crept into the code in the PythonEngine.pas in line 4396 for the "I":

 

badchar.thumb.png.c163651411b1933270560743c0bbb18e.png

 

Best regards

Share this post


Link to post
21 minutes ago, Soulflesh said:

Unfortunately a wrong character

Thanks..  It is now fixed.

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

×