Recent

Author Topic: compile pascal source on Linux by FPC ?  (Read 467 times)

tissatussa

  • Newbie
  • Posts: 4
compile pascal source on Linux by FPC ?
« on: August 28, 2022, 03:05:25 pm »
hi, to compile a chess engine (Booot v6.5) i downloaded a set .pas files (with .dpr and .dproj file) but i'm not able to compile it on Linux (Xubuntu 22.04) .. i have FPC v3.2.2 installed and even Lazarus, but i'm stuck .. in terminal i tried :

Code: Pascal  [Select][+][-]
  1. $ fpc ./booot6.dpr
  2. Free Pascal Compiler version 3.2.2+dfsg-9ubuntu1 [2022/04/11] for x86_64
  3. Copyright (c) 1993-2021 by Florian Klaempfl and others
  4. Target OS: Linux for x86-64
  5. Compiling ./booot6.dpr
  6. Compiling uBitBoards.pas
  7. Compiling uMagic.pas
  8. uMagic.pas(91,6) Error: Identifier not found "Result"
  9. uMagic.pas(113,5) Error: Identifier not found "Result"
  10. uMagic.pas(135,5) Error: Identifier not found "Result"
  11. uMagic.pas(147,5) Error: Identifier not found "Result"
  12. uMagic.pas(157,5) Error: Identifier not found "Result"
  13. uMagic.pas(171,4) Error: Identifier not found "result"
  14. uMagic.pas(177,5) Error: Identifier not found "result"
  15. uMagic.pas(182,5) Error: Identifier not found "result"
  16. uMagic.pas(212,4) Error: Identifier not found "Result"
  17. uMagic.pas(347,11) Error: Identifier not found "Result"
  18. uMagic.pas(362,4) Error: Identifier not found "Result"
  19. uMagic.pas(421) Fatal: There were 11 errors compiling module, stopping
  20. Fatal: Compilation aborted
  21. Error: /usr/bin/ppcx64 returned an error exitcode

the package does not have any README file .. do i need to add some parameters / options ?
i'm not a beginner at Linux, but i never did any Pascal.
i guess compiling my source should be pretty simple .. can anybody help me out ?

Fred vS

  • Hero Member
  • *****
  • Posts: 2836
    • StrumPract is the musicians best friend
Re: compile pascal source on Linux by FPC ?
« Reply #1 on: August 28, 2022, 03:10:38 pm »
Hello.

Try to compile after adding this at begin of unit ( after: unit uMagic; )
Code: Pascal  [Select][+][-]
  1. {$mode delphi} {$h+}

[EDIT] You may also use the mode parameter for fpc:
Code: Pascal  [Select][+][-]
  1. $ fpc -Mdelphi ./booot6.dpr

[EDIT2] You may also try the excellent "pure fpc" chess engine from Roland:
https://gitlab.com/rchastain/moustique
« Last Edit: August 28, 2022, 03:53:45 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

tissatussa

  • Newbie
  • Posts: 4
Re: compile pascal source on Linux by FPC ?
« Reply #2 on: August 28, 2022, 03:46:24 pm »
indeed, the first line of 'uMagic.pas' is 'unit uMagic;' so i added '{$mode delphi} {$h+}' on the next line, as you suggest, but now i get this error :

Code: Pascal  [Select][+][-]
  1. $ fpc ./booot6.dpr
  2. Free Pascal Compiler version 3.2.2+dfsg-9ubuntu1 [2022/04/11] for x86_64
  3. Copyright (c) 1993-2021 by Florian Klaempfl and others
  4. Target OS: Linux for x86-64
  5. Compiling ./booot6.dpr
  6. Compiling uBitBoards.pas
  7. Compiling uMagic.pas
  8. uMagic.pas(405,6) Warning: Label not defined "l1"
  9. Compiling uBoard.pas
  10. Compiling uAttacks.pas
  11. uAttacks.pas(30,4) Error: Identifier not found "Result"
  12. uAttacks.pas(34,4) Error: Identifier not found "Result"
  13. uAttacks.pas(38,4) Error: Identifier not found "Result"
  14. uAttacks.pas(42,4) Error: Identifier not found "Result"
  15. uAttacks.pas(46,4) Error: Identifier not found "Result"
  16. uAttacks.pas(63,3) Error: Identifier not found "Result"
  17. uAttacks.pas(69,4) Error: Identifier not found "Result"
  18. uAttacks.pas(91,7) Error: Identifier not found "Result"
  19. uAttacks.pas(99,7) Error: Identifier not found "Result"
  20. uAttacks.pas(103,3) Error: Identifier not found "Result"
  21. uAttacks.pas(123,3) Error: Identifier not found "Result"
  22. uAttacks.pas(132,3) Error: Identifier not found "Result"
  23. uAttacks.pas(139,7) Error: Identifier not found "Result"
  24. uAttacks.pas(145,6) Error: Identifier not found "Result"
  25. uAttacks.pas(152,6) Error: Identifier not found "Result"
  26. uAttacks.pas(161,7) Error: Identifier not found "Result"
  27. uAttacks.pas(178,7) Error: Identifier not found "Result"
  28. uAttacks.pas(186,9) Error: Identifier not found "Result"
  29. uAttacks.pas(187,9) Error: Identifier not found "Result"
  30. uAttacks.pas(196,3) Error: Identifier not found "Result"
  31. uAttacks.pas(200,9) Error: Identifier not found "Result"
  32. uAttacks.pas(206,3) Error: Identifier not found "Result"
  33. uAttacks.pas(209,7) Error: Identifier not found "Result"
  34. uAttacks.pas(214,7) Error: Identifier not found "Result"
  35. uAttacks.pas(219,7) Error: Identifier not found "Result"
  36. uAttacks.pas(229,3) Error: Identifier not found "Result"
  37. uAttacks.pas(237,7) Error: Identifier not found "Result"
  38. uAttacks.pas(282,3) Error: Identifier not found "Result"
  39. uAttacks.pas(333,7) Error: Identifier not found "Result"
  40. uAttacks.pas(341,3) Error: Identifier not found "Result"
  41. uAttacks.pas(356,7) Error: Identifier not found "Result"
  42. uAttacks.pas(375,7) Error: Identifier not found "Result"
  43. uAttacks.pas(397,3) Error: Identifier not found "Result"
  44. uAttacks.pas(403,7) Error: Identifier not found "Result"
  45. uAttacks.pas(406,3) Error: Identifier not found "Result"
  46. uAttacks.pas(409) Fatal: There were 35 errors compiling module, stopping
  47. Fatal: Compilation aborted
  48. Error: /usr/bin/ppcx64 returned an error exitcode

your second option didn't succeed either :

Code: Pascal  [Select][+][-]
  1. $ fpc --Mdelphi ./booot6.dpr
  2. Error: Illegal parameter: --Mdelphi
  3. Error: /usr/bin/ppcx64 returned an error exitcode

it failed .. i guess your '--' should be '-' so i did this, but it also failed :

Code: Pascal  [Select][+][-]
  1. $ fpc -Mdelphi ./booot6.dpr
  2. Free Pascal Compiler version 3.2.2+dfsg-9ubuntu1 [2022/04/11] for x86_64
  3. Copyright (c) 1993-2021 by Florian Klaempfl and others
  4. Target OS: Linux for x86-64
  5. Compiling ./booot6.dpr
  6. Compiling uBitBoards.pas
  7. Compiling uMagic.pas
  8. uMagic.pas(403,6) Warning: Label not defined "l1"
  9. Compiling uBoard.pas
  10. Compiling uAttacks.pas
  11. uAttacks.pas(406,11) Note: Call to subroutine "function SquareAttackedBB(sq:LongInt;AllPieses:Int64;var Board:TBoard):Int64;" marked as inline is not inlined
  12. uAttacks.pas(406,11) Note: Call to subroutine "function FindMinAttacker(Square:LongInt;MyAttackers:Int64;var Occupied:Int64;var Attackers:Int64;var Board:TBoard):LongInt;" marked as inline is not inlined
  13. Compiling uHash.pas
  14. uHash.pas(4,40) Fatal: Can't find unit Ansistrings used by uHash
  15. Fatal: Compilation aborted
  16. Error: /usr/bin/ppcx64 returned an error exitcode


Fred vS

  • Hero Member
  • *****
  • Posts: 2836
    • StrumPract is the musicians best friend
Re: compile pascal source on Linux by FPC ?
« Reply #3 on: August 28, 2022, 03:51:45 pm »
Hum, difficult to give a diagnostic without seeing the source...  :-[

Maybe in uHash.pas, in uses section,  remove Ansistrings unit.

Quote
it failed .. i guess your '--' should be '-'
Ooops, yes, fixed in previous post.
« Last Edit: August 28, 2022, 03:55:29 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

tissatussa

  • Newbie
  • Posts: 4
Re: compile pascal source on Linux by FPC ?
« Reply #4 on: August 28, 2022, 03:56:43 pm »
i can put a ZIP with the source here.

your newest option (compile the Moustique chess engine) DID succeed according to the compilation line on that page : i get a working binary.

MarkMLl

  • Hero Member
  • *****
  • Posts: 5560
Re: compile pascal source on Linux by FPC ?
« Reply #5 on: August 28, 2022, 04:05:18 pm »
i can put a ZIP with the source here.

your newest option (compile the Moustique chess engine) DID succeed according to the compilation line on that page : i get a working binary.

Welcome to the forum, and congratulations on an exemplary first message: a clear statement of what you were trying to do, the compiler version etc. clearly shown in the message (rather than in the sig), and full error messages.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

hansotten

  • Jr. Member
  • **
  • Posts: 74
Re: compile pascal source on Linux by FPC ?
« Reply #6 on: August 28, 2022, 04:07:29 pm »
I had a look at the booot 6.5 sources. Looks like Windows is involved (handles).
Doubt it will run as is n Linux.


Fred vS

  • Hero Member
  • *****
  • Posts: 2836
    • StrumPract is the musicians best friend
Re: compile pascal source on Linux by FPC ?
« Reply #7 on: August 28, 2022, 04:11:44 pm »
i can put a ZIP with the source here.

Hum, it will not be "out-of-the-box" to compile this project for Linux because there are many call to the "Windows" unit, like GetStdHandle, STD_INPUT_HANDLE, etc...
But, with some (many) cups coffee, and many {$ifndef mswindows} ... {$else} ... {$endif} it is doable.
« Last Edit: August 28, 2022, 04:39:35 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

tissatussa

  • Newbie
  • Posts: 4
Re: compile pascal source on Linux by FPC ?
« Reply #8 on: August 28, 2022, 04:15:24 pm »
thanks for pointing this out .. i often find sources (of other chess engines, in C, C++, D, etc) which are typical for Windows and they also are hard to convert / adjust for Linux .. sometimes i succeed, but it's rare.  I leave it for now .. nevermind.

Fred vS

  • Hero Member
  • *****
  • Posts: 2836
    • StrumPract is the musicians best friend
Re: compile pascal source on Linux by FPC ?
« Reply #9 on: August 28, 2022, 04:51:47 pm »
If you are interested by Chess engine-program, here other excellent fpc projects compatible for Windows and Unix OS (all done by Roland Chastain):

Chess engines:
https://gitlab.com/rchastain/mater
https://github.com/rchastain/alouette

Chess programs:
https://github.com/rchastain/nero5
https://github.com/rchastain/eschecs
« Last Edit: August 28, 2022, 04:57:22 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Roland57

  • Sr. Member
  • ****
  • Posts: 310
Re: compile pascal source on Linux by FPC ?
« Reply #10 on: August 28, 2022, 05:21:21 pm »
Thank you Fred!

@tissatussa

Some time ago I made a Linux-compatible version of Booot 4.15. If you are interested, you can find it here. I think it behaves the same as the original.

I also tried with Booot 6 and succeeded to make a working version, but with wild modifications, so I prefer not to distribute it.

P.-S. There is another very strong Pascal chess program that I ported to Linux: Open Critter. But there are still things to fix. It crashes sometimes.
« Last Edit: August 28, 2022, 06:12:58 pm by Roland57 »

PascalDragon

  • Hero Member
  • *****
  • Posts: 4744
  • Compiler Developer
Re: compile pascal source on Linux by FPC ?
« Reply #11 on: August 28, 2022, 05:30:50 pm »
Try to compile after adding this at begin of unit ( after: unit uMagic; )
Code: Pascal  [Select][+][-]
  1. {$mode delphi} {$h+}

Please note that {$H+} is not required for mode Delphi as that is enabled by default when that mode is selected (for a very long time already).

Fred vS

  • Hero Member
  • *****
  • Posts: 2836
    • StrumPract is the musicians best friend
Re: compile pascal source on Linux by FPC ?
« Reply #12 on: August 28, 2022, 05:51:17 pm »
Try to compile after adding this at begin of unit ( after: unit uMagic; )
Code: Pascal  [Select][+][-]
  1. {$mode delphi} {$h+}

Please note that {$H+} is not required for mode Delphi as that is enabled by default when that mode is selected (for a very long time already).

Ha, ok, thanks for the tip.  ;)

(Please note too that it is a very, very long time already that I did not use that mode.  :-X)
« Last Edit: August 28, 2022, 05:53:05 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

 

TinyPortal © 2005-2018