Lazarus

Free Pascal => General => Topic started by: Roland57 on April 13, 2021, 07:52:57 am

Title: Cannot compile fpde: Illegal type conversion
Post by: Roland57 on April 13, 2021, 07:52:57 am
Hello!

I would like to compile fpde (fpc/utils/fpdoc/fpde) on Linux 64, with FPC 3.2.0.

I get this error:

frmmain.pp(152,66) Error: Illegal type conversion: "TTagType" to "Pointer"
frmmain.pp(158,72) Error: Illegal type conversion: "TTagType" to "Pointer"
frmmain.pp(711,11) Error: Illegal type conversion: "Pointer" to "TNodeType"
frmmain.pp(748,27) Error: Illegal type conversion: "Pointer" to "TTagType"


Would someone know how to fix it?

Regards.

Roland
Title: Re: Cannot compile fpde: Illegal type conversion
Post by: Roland57 on April 13, 2021, 09:09:36 am
I believe I found the solution.

Code: Pascal  [Select][+][-]
  1. Function TMainForm.FormatMenuItem(ACaption : String; tt : TTagType) : TFPgtkMenuItem;
  2.  
  3. begin
  4.   //Result:=NewMenuItem(ACaption,FormatHint(ACaption),'',@TagClick,Pointer(tt));
  5.   Result:=NewMenuItem(ACaption,FormatHint(ACaption),'',@TagClick,@tt);

Code: Pascal  [Select][+][-]
  1. Procedure TMainForm.TagClick(Sender : TFPGtkObject; Data : Pointer);
  2.  
  3. begin
  4.   //CurrentEditor.InsertTag(TTagType(Data));
  5.   CurrentEditor.InsertTag(TTagType(Data^));

Now I get this:

Linking ./fpde
/usr/bin/ld : ne peut trouver -lgtk
fpde.pp(13,1) Error: Error while linking


but this is another story.  :)
Title: Re: Cannot compile fpde: Illegal type conversion
Post by: Roland57 on April 13, 2021, 09:20:59 am
Would it be much work to port the application from GTK to GTK2?

Would you know where I can find an example of a GTK2 application?
Title: Re: Cannot compile fpde: Illegal type conversion
Post by: marcov on April 13, 2021, 09:24:11 am
Lazarus generates GTK2 applications. But since Lazarus acquired a win32 backend in the 2003-2005, (any) GTK on Windows has been rare.

Title: Re: Cannot compile fpde: Illegal type conversion
Post by: Roland57 on April 13, 2021, 09:39:50 am
Lazarus generates GTK2 applications. But since Lazarus acquired a win32 backend in the 2003-2005, (any) GTK on Windows has been rare.

Thank you for your answer, but I don't really understand.  :-[

I was wondering if it were possible to do a simple modification to fpde source, so I can compile and link it on my computer (where there is GTK2, but no GTK)?
Title: Re: Cannot compile fpde: Illegal type conversion
Post by: Fred vS on April 13, 2021, 11:54:36 am
I would like to compile fpde (fpc/utils/fpdoc/fpde) on Linux 64, with FPC 3.2.0.

Hello Roland.

Where did you find /fpc/utils/fpdoc/fpde ?
Here on source of fpc 3.2.0 and 3.2.2 I dont find it.

Also, if it exists and if it is in directory /fpc/utils, it should not need GTK (IMHO GTK is a LCL-Lazarus thing).

Fre;D
Title: Re: Cannot compile fpde: Illegal type conversion
Post by: Roland57 on April 13, 2021, 12:02:13 pm
Where did you find /fpc/utils/fpdoc/fpde ?
Here on source of fpc 3.2.0 and 3.2.2 I dont find it.

In the directory of a Lazarus  version installed with fpcupdeluxe.

.
Also, if it exists and if it is in directory /fpc/utils, it should not need GTK (IMHO GTK is a LCL-Lazarus thing).

It's a plain Free Pascal program, and it uses GTK.  :)

Code: Pascal  [Select][+][-]
  1. unit frmmain;
  2.  
  3. interface
  4.  
  5. uses
  6.   gtk,gdk,fpgtk,fpgtkext,pgEditor,frmlink,sysutils,classes,fpdeopts;
Title: Re: Cannot compile fpde: Illegal type conversion
Post by: lucamar on April 13, 2021, 12:10:28 pm
Where did you find /fpc/utils/fpdoc/fpde ?
Here on source of fpc 3.2.0 and 3.2.2 I dont find it.

In this computer, for example, it's on:
/usr/share/fpcsrc/3.2.0/utils/fpdoc/fpde/

Quote
Also, if it exists and if it is in directory /fpc/utils, it should not need GTK (IMHO GTK is a LCL-Lazarus thing).

The problem is that it is a GTK program but instead of the LCL it uses the low level GTK bindings:
Code: Pascal  [Select][+][-]
  1. program fpde;
  2. {$mode objfpc}
  3. {$H+}
  4. { $apptype gui}
  5.  
  6. uses fpgtk,fpglib,fpgtkext,frmmain,pgeditor;
  7.  
  8. begin
  9.   application := TFPgtkApplication.Create;
  10.   application.MainWindow := TMainForm.Create;
  11.   application.Run;
  12.   application.Free;
  13. end.
Code: Pascal  [Select][+][-]
  1. {$mode objfpc}
  2. {$h+}
  3. unit frmmain;
  4.  
  5. interface
  6.  
  7. uses
  8.   gtk,gdk,fpgtk,fpgtkext,pgEditor,frmlink,sysutils,classes,fpdeopts;
  9.  
  10. Const
  11.   DefaultTooltips = True;
  12.   DefaultToolBarStyle = GTK_TOOLBAR_ICONS;
  13.   DefaultToolbarRelief = GTK_RELIEF_NONE;
  14.   SFileTemplate = 'template.xml';
  15.  
  16. Type
  17.   TNodeType = (ntfile,ntPackage,ntModule,ntElement,ntTopic);
  18.  
  19.   TMainForm = Class(TFPGtkWindow)
  20. {... etc ...}
Title: Re: Cannot compile fpde: Illegal type conversion
Post by: Fred vS on April 13, 2021, 12:12:51 pm
In the directory of a Lazarus  version installed with fpcupdeluxe.

Ooops, I see it now, fpde is a directory and in this directory is /fpc/utils/fpdoc/fpde/fpde.pp


It's a plain Free Pascal program, and it uses GTK.  :)

Code: Pascal  [Select][+][-]
  1. unit frmmain;
  2.  
  3. interface
  4.  
  5. uses
  6.   gtk,gdk,fpgtk,fpgtkext,pgEditor,frmlink,sysutils,classes,fpdeopts;

Hum, mwouais, maybe, but usually something that uses GTK should be a Lazarus program and not plain pure Free Pascal program.

Fre;D
Title: Re: Cannot compile fpde: Illegal type conversion
Post by: marcov on April 13, 2021, 12:16:47 pm
FPDE uses fpgtk which is a (not related) precursor to fpgui. fpgtk is a simple object oriented wrapper around GTK1.

FPDE itself is a precursor to fpdoc based editors in Lazarus.

Upgrade options are unknown, build status unknown. Wouldn't be surprised if it hasn't been compiled after 2005-2008 period.

Title: Re: Cannot compile fpde: Illegal type conversion
Post by: Fred vS on April 13, 2021, 12:17:17 pm
@ Lucamar: Ooops, perdona for my previous post that says the same as you.

Fre;D
Title: Re: Cannot compile fpde: Illegal type conversion
Post by: lucamar on April 13, 2021, 12:21:48 pm
@ Lucamar: Ooops, perdona for my previous post that says the same than you.
No problem. Quasi-simultaneous posts are quite normal in web fora :)
Title: Re: Cannot compile fpde: Illegal type conversion
Post by: Roland57 on April 13, 2021, 12:25:32 pm
FPDE uses fpgtk which is a (not related) precursor to fpgui. fpgtk is a simple object oriented wrapper around GTK1.

FPDE itself is a precursor to fpdoc based editors in Lazarus.

Upgrade options are unknown, build status unknown. Wouldn't be surprised if it hasn't been compiled after 2005-2008 period.

OK, so I will rather try the Lazarus Documentation Editor (https://wiki.freepascal.org/Lazarus_Documentation_Editor), or even edit XML in my favourite text editor.  :)

Regards.

Roland
Title: Re: Cannot compile fpde: Illegal type conversion
Post by: Fred vS on April 13, 2021, 12:33:40 pm
FPDE uses fpgtk which is a (not related) precursor to fpgui. fpgtk is a simple object oriented wrapper around GTK1.

FPDE itself is a precursor to fpdoc based editors in Lazarus.

Upgrade options are unknown, build status unknown. Wouldn't be surprised if it hasn't been compiled after 2005-2008 period.

OK, so I will rather try the Lazarus Documentation Editor (https://wiki.freepascal.org/Lazarus_Documentation_Editor), or even edit XML in my favourite text editor.  :)

Regards.

Roland

Or you may install GTK1, following this (https://wiki.lazarus.freepascal.org/GTK1_Interface)

on a Debian distro, just do:

Code: Pascal  [Select][+][-]
  1. sudo apt-get update
  2. sudo apt-get install glib glib-shlibs gtk+-shlibs gdk-pixbuf gdk-pixbuf-shlibs
Title: Re: Cannot compile fpde: Illegal type conversion
Post by: Roland57 on April 13, 2021, 01:07:55 pm
Or you may install GTK1, following this (https://wiki.lazarus.freepascal.org/GTK1_Interface)

on a Debian distro, just do:

Good idea. I will try this. But I don't have a Debian distro. I will ask the question to my fellows who use Mageia.
Title: Re: Cannot compile fpde: Illegal type conversion
Post by: PascalDragon on April 13, 2021, 01:25:32 pm
It's a plain Free Pascal program, and it uses GTK.  :)

Code: Pascal  [Select][+][-]
  1. unit frmmain;
  2.  
  3. interface
  4.  
  5. uses
  6.   gtk,gdk,fpgtk,fpgtkext,pgEditor,frmlink,sysutils,classes,fpdeopts;

Hum, mwouais, maybe, but usually something that uses GTK should be a Lazarus program and not plain pure Free Pascal program.

In a Lazarus application wouldn't find direct uses of units like gtk or gdk. Also nothing stops users from writing non-LCL GUI applications that directly interface to the widgetset, be it GTK, Qt, Win32, Cocoa, MUI or whatever.
Title: Re: Cannot compile fpde: Illegal type conversion
Post by: Roland57 on April 15, 2021, 06:53:42 am
Finally, following Fred advice, I could compile, link and execute fpde.

In case someone is interested to install GTK1 on Mageia or similar distribution, the solution is here (https://www.mageialinux-online.org/forum/topic-28807-1+installer-gtk.php#m285274).

Thanks for your help.
TinyPortal © 2005-2018