Recent

Author Topic: [Solved] Need help with compiling .pas file  (Read 893 times)

nikel

  • Sr. Member
  • ****
  • Posts: 267
[Solved] Need help with compiling .pas file
« on: December 05, 2025, 04:05:58 am »
Hello, I'm trying to compile my pascal file with Lazarus units using FPC. I'm getting error:

Quote
Target OS: Linux for x86-64
Compiling autodj.pas
autodj.pas(61,16) Warning: An inherited method is hidden by "destructor Destroy;"
Compiling /usr/share/fpcsrc/3.2.2/rtl/linux/si_c.pp
sysnr.inc(21,1) Fatal: Internal error 200501156
Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode

Here's how I declare types / variables:

Code: Pascal  [Select][+][-]
  1. program AutoDJ;
  2.  
  3. {$mode objfpc}
  4. {$codepage UTF8}
  5. {$m+}
  6.  
  7. uses
  8.   {$IFDEF UNIX}
  9.   CThreads,
  10.   {$ENDIF}
  11.   Classes, SysUtils,
  12.   StrUtils,
  13.   LazUTF8;
  14.  
  15. type
  16.   TParameters = class
  17.   private
  18.     IsIndex     : Boolean;
  19.     IsVersion   : Boolean;
  20.     IsKey       : Boolean;
  21.     IsBPM       : Boolean;
  22.     IsArtist    : Boolean;
  23.     IsYear      : Boolean;
  24.   public
  25.     constructor Create(I: Boolean; V: Boolean; K: Boolean; B: Boolean; A: Boolean; Y: Boolean);
  26.  
  27.     procedure SetIsIndex(I: Boolean);
  28.     function GetIsIndex (): Boolean;
  29.    
  30.     procedure SetIsVersion(V: Boolean);
  31.     function GetIsVersion(): Boolean;
  32.  
  33.     procedure SetIsKey(K: Boolean);
  34.     function GetIsKey(): Boolean;
  35.  
  36.     procedure SetIsBPM(B: Boolean);
  37.     function GetIsBPM(): Boolean;
  38.    
  39.     procedure SetIsArtist(A: Boolean);
  40.     function GetIsArtist(): Boolean;
  41.  
  42.     procedure SetIsYear(Y: Boolean);
  43.     function GetIsYear(): Boolean;
  44.  
  45.     procedure Apply;
  46.   end;
  47.  
  48.   {TMain}
  49.  
  50.   TMain = class
  51.   type
  52.     TParameters = AutoDJ.TParameters;
  53.   protected
  54.     DebugMode       : Boolean;
  55.     Parameters      : TParameters;
  56.   public
  57.     constructor Create(D: Boolean);
  58.     destructor Destroy;
  59.  
  60.     procedure SetDebugMode(D: Boolean);
  61.     function GetDebugMode(): Boolean;
  62.  
  63.     procedure WritePath();
  64.   end;
  65.  
  66. resourcestring
  67.   EDirectoryNotExists = 'Directory doesn''t exist: %s';

My script for compiling:

Code: Bash  [Select][+][-]
  1. #!/bin/bash
  2. fpc -Fu/usr/share/lazarus/4.4.0/lcl/                    \
  3.     -Fu/usr/share/lazarus/4.4.0/components/lazutils/    \
  4.     -Fu/usr/share/lazarus/4.4.0/lcl/widgetset/          \
  5.     -Fu/usr/share/fpcsrc/3.2.2/rtl/linux                \
  6.     -Fu/usr/share/lazarus/4.4.0/lcl/nonwin32/           \
  7.     -Fu/usr/share/fpcsrc/3.2.2/packages/pasjpeg/src/    \
  8.     -Fi/usr/share/lazarus/4.4.0/lcl/include/            \
  9.     -Fi/usr/share/fpcsrc/3.2.2/rtl/inc/                 \
  10.     -Fi/usr/share/fpcsrc/3.2.2/rtl/linux                \
  11.     -Fi/usr/share/fpcsrc/3.2.2/rtl/x86_64/              \
  12.     -Fi/usr/share/fpcsrc/3.2.2/rtl/unix/                \
  13.     -Fi/usr/share/fpcsrc/3.2.2/rtl/win/                 \
  14.     -Fi/usr/share/fpcsrc/3.2.2/rtl/linux/x86_64/        \
  15.     -FU./lib                                            \
  16.     -Mobjfpc                                            \
  17.     autodj.pas

How can I fix this error?

Modify: I deleted contents of Lib folder and am getting a different error: autodj.pas(10,3) Fatal: Can't find unit cthreads used by AutoDJ
« Last Edit: December 07, 2025, 04:57:35 pm by nikel »

dbannon

  • Hero Member
  • *****
  • Posts: 3647
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Need help with compiling .pas file
« Reply #1 on: December 05, 2025, 06:44:36 am »
Hmm, si_c.pp is part of the FPC rtl, as such, assuming you installed from your Linux's repo, should be recompiled and ready to use as such.  Have you deleted anything or edited anything up there ?

Those files are currently in root space, not your user space.  This would only normally happen if you have been running as root, a very bad thing to do. You may need to rebuild the run time library or, probably easier, reinstall FPC.

For the record, if you do want to mess around with FPC files, download the source of fpc323 and build and install in your own space.
 
Davo

Edit : another possibility is your fpc.cfg file is not pointing to where the .ppu files are, has that been edited ?  For a repo install thats /etc/fpc.cfg but a local file in your home directory or working dir will override that.

Code: Bash  [Select][+][-]
  1. $> find /usr -name "si_c.pp*" 2>/dev/null

Might be interesting.
« Last Edit: December 05, 2025, 07:32:46 am by dbannon »
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Thausand

  • Sr. Member
  • ****
  • Posts: 457
Re: Need help with compiling .pas file
« Reply #2 on: December 05, 2025, 08:33:29 am »
I have add there no need for build compiler. Build compiler and build project is 2 separate action. Then there no need for have -Fu have directory for source.

Is guess but this lazarus have try recompile compiler. As write dbannon is problem with have access for location or is use error setting for fpc.cfg

fwiw: si_c.pp is part compiler and no ever have compile that when compile project. This is indicate something wrong with compiler/configuration (lazarus or fpc).

nikel

  • Sr. Member
  • ****
  • Posts: 267
Re: Need help with compiling .pas file
« Reply #3 on: December 05, 2025, 01:49:28 pm »
Thanks for the replies. I was unsure it was a clever idea to use Lazarus units without installing it. I hoped so.

dbannon

  • Hero Member
  • *****
  • Posts: 3647
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Need help with compiling .pas file
« Reply #4 on: December 06, 2025, 01:02:16 am »
Thats a puzzling response Nikel. Your problem here is a FPC Unit, not a Lazarus Unit.

If you a using a "built from source" Lazarus directly (ie without installing) thats great, exactly what I recommend. But fix, one way or another, your FPC problem. Please remember that FPC and Lazarus are two different things, they work closely together, Lazarus is totally dependent on FPC but not the same thing.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

nikel

  • Sr. Member
  • ****
  • Posts: 267
Re: Need help with compiling .pas file
« Reply #5 on: December 07, 2025, 04:57:02 pm »
I just copied the command from somewhere else and didn't read it carefully. Thanks for the hint. This works fine:

Code: Pascal  [Select][+][-]
  1. #!/bin/bash
  2. rm -R ./lib/*
  3. fpc -Fu/usr/share/lazarus/4.4.0/lcl/                    \
  4.     -Fu/usr/share/lazarus/4.4.0/components/lazutils/    \
  5.     -Fu/usr/share/lazarus/4.4.0/lcl/widgetset/          \
  6.     -Fu/usr/lib/fpc/3.2.2/units/rtl/linux               \
  7.     -Fu/usr/share/lazarus/4.4.0/lcl/nonwin32/           \
  8.     -Fu/usr/share/fpcsrc/3.2.2/packages/pasjpeg/src/    \
  9.     -Fi/usr/share/lazarus/4.4.0/lcl/include/            \
  10.     -Fi/usr/lib/fpc/3.2.2/units/rtl/inc/                \
  11.     -Fi/usr/lib/fpc/3.2.2/units/rtl/linux               \
  12.     -Fi/usr/lib/fpc/3.2.2/units/rtl/x86_64/             \
  13.     -Fi/usr/lib/fpc/3.2.2/units/rtl/unix/               \
  14.     -Fi/usr/lib/fpc/3.2.2/units/rtl/win/                \
  15.     -Fi/usr/lib/fpc/3.2.2/units/rtl/linux/x86_64/       \
  16.     -FU./lib                                            \
  17.     -Mobjfpc                                            \
  18.     autodj.pas
« Last Edit: December 07, 2025, 05:01:24 pm by nikel »

Thausand

  • Sr. Member
  • ****
  • Posts: 457
Re: [Solved] Need help with compiling .pas file
« Reply #6 on: December 07, 2025, 08:03:53 pm »
If no want use lazarus project (then no lazbuild) and want use fpc command and no use fpc.cfg then is more short solute:
Code: Bash  [Select][+][-]
  1. fpcunitdir="/usr/lib/fpc"
  2. lazdir="/usr/share/lazarus"
  3. lazver="4.4.0"
  4.  
  5. fpc \
  6.   -Mobjfpc \
  7.   -B \
  8.   -Sc \
  9.   autodj.pas \
  10.   -FU"./lib"
  11.   -Fu"$fpc_unitdir/\$fpcversion/units/\$fpctarget/rtl" \
  12.   -Fu"$fpc_unitdir/\$fpcversion/units/\$fpctarget/\*" \
  13.   -Fu"$lazdir/$lazver/components/\*"
  14.  

This is what is write for fpc.cfg and fpc is use. https://www.freepascal.org/docs-html/user/usersu10.html and https://wiki.freepascal.org/Configuration_file

There no use -Fi for include and have separate directory when can have asteriks.

Have suggest for good read command line option: https://www.freepascal.org/docs-html/user/userap1.html

Have add begin end for program to have compile then can see missing (is expect  :) ).
Code: [Select]
....
[0.828] Searching file autodj.pas... found
[0.828] autodj.pas(15,1) (AUTODJ)   Parsing implementation of autodj.pas
[0.828] autodj.pas(58,16) Warning: An inherited method is hidden by "destructor Destroy;"
[0.828] autodj.pas(50,11) Hint: Local type "TMain" is not used
[0.828] autodj.pas(67,3) Hint: Local const "EDirectoryNotExists" is not used
[0.828] autodj.pas(18,5) Note: Private field "TParameters.IsIndex" is never used
[0.828] autodj.pas(19,5) Note: Private field "TParameters.IsVersion" is never used
[0.828] autodj.pas(20,5) Note: Private field "TParameters.IsKey" is never used
[0.828] autodj.pas(21,5) Note: Private field "TParameters.IsBPM" is never used
[0.828] autodj.pas(22,5) Note: Private field "TParameters.IsArtist" is never used
[0.828] autodj.pas(23,5) Note: Private field "TParameters.IsYear" is never used
[0.828] autodj.pas(25,17) Error: Forward declaration not solved "constructor Create(Boolean;Boolean;Boolean;Boolean;Boolean;Boolean);"
[0.828] autodj.pas(27,15) Error: Forward declaration not solved "SetIsIndex(Boolean);"
[0.828] autodj.pas(28,14) Error: Forward declaration not solved "GetIsIndex:Boolean;"
[0.828] autodj.pas(30,15) Error: Forward declaration not solved "SetIsVersion(Boolean);"
[0.828] autodj.pas(31,14) Error: Forward declaration not solved "GetIsVersion:Boolean;"
[0.828] autodj.pas(33,15) Error: Forward declaration not solved "SetIsKey(Boolean);"
[0.828] autodj.pas(34,14) Error: Forward declaration not solved "GetIsKey:Boolean;"
[0.828] autodj.pas(36,15) Error: Forward declaration not solved "SetIsBPM(Boolean);"
[0.828] autodj.pas(37,14) Error: Forward declaration not solved "GetIsBPM:Boolean;"
[0.828] autodj.pas(39,15) Error: Forward declaration not solved "SetIsArtist(Boolean);"
[0.828] autodj.pas(40,14) Error: Forward declaration not solved "GetIsArtist:Boolean;"
[0.828] autodj.pas(42,15) Error: Forward declaration not solved "SetIsYear(Boolean);"
[0.828] autodj.pas(43,14) Error: Forward declaration not solved "GetIsYear:Boolean;"
[0.828] autodj.pas(45,15) Error: Forward declaration not solved "Apply;"
[0.828] autodj.pas(57,17) Error: Forward declaration not solved "constructor Create(Boolean);"
[0.828] autodj.pas(58,16) Error: Forward declaration not solved "destructor Destroy;"
[0.828] autodj.pas(60,15) Error: Forward declaration not solved "SetDebugMode(Boolean);"
[0.828] autodj.pas(61,14) Error: Forward declaration not solved "GetDebugMode:Boolean;"
[0.828] autodj.pas(63,15) Error: Forward declaration not solved "WritePath;"
[0.828] autodj.pas(12,3) Hint: Unit "StrUtils" not used in AutoDJ
[0.828] autodj.pas(70,4) Fatal: There were 19 errors compiling module, stopping
[0.852] Fatal: Compilation aborted
« Last Edit: December 07, 2025, 08:11:16 pm by Thausand »

PascalDragon

  • Hero Member
  • *****
  • Posts: 6283
  • Compiler Developer
Re: [Solved] Need help with compiling .pas file
« Reply #7 on: December 08, 2025, 10:42:40 pm »
Code: Bash  [Select][+][-]
  1. #!/bin/bash
  2. fpc -Fu/usr/share/lazarus/4.4.0/lcl/                    \
  3.     -Fu/usr/share/lazarus/4.4.0/components/lazutils/    \
  4.     -Fu/usr/share/lazarus/4.4.0/lcl/widgetset/          \
  5.     -Fu/usr/share/fpcsrc/3.2.2/rtl/linux                \
  6.     -Fu/usr/share/lazarus/4.4.0/lcl/nonwin32/           \
  7.     -Fu/usr/share/fpcsrc/3.2.2/packages/pasjpeg/src/    \
  8.     -Fi/usr/share/lazarus/4.4.0/lcl/include/            \
  9.     -Fi/usr/share/fpcsrc/3.2.2/rtl/inc/                 \
  10.     -Fi/usr/share/fpcsrc/3.2.2/rtl/linux                \
  11.     -Fi/usr/share/fpcsrc/3.2.2/rtl/x86_64/              \
  12.     -Fi/usr/share/fpcsrc/3.2.2/rtl/unix/                \
  13.     -Fi/usr/share/fpcsrc/3.2.2/rtl/win/                 \
  14.     -Fi/usr/share/fpcsrc/3.2.2/rtl/linux/x86_64/        \
  15.     -FU./lib                                            \
  16.     -Mobjfpc                                            \
  17.     autodj.pas

How can I fix this error?

First start by not adding the fpcsrc paths. You should work with a precompiled FPC distribution unless you really know what you're doing and you asking this question means that you don't. So ensure that the library path to units/x86_64-linux in the fpc.cfg is setup correctly and then compile your code without the fpcsrc paths.

dbannon

  • Hero Member
  • *****
  • Posts: 3647
    • tomboy-ng, a rewrite of the classic Tomboy
Re: [Solved] Need help with compiling .pas file
« Reply #8 on: December 09, 2025, 12:08:43 am »
Just jumping back to nikel's last post, he/she said it now works using the command line in that post.

While thats good its worth noting its excessively long and (unless scripted) error prone.
nikel please note :
  • all the entries mentioning .../fpc/3.2.2/... should already be in your fpc.cfg file.
  • The one with share/fpcsrc/3.2.2 almost certainly should not be there.
  • You include paths to Lazarus Units but its not clear to me that your app is, in fact a Lazarus / LCL app.


The last point indicates, maybe a very old code written before Lazarus Projects existed ?   If so, far, far better create a new, conventional, Lazarus project and add the source units to it. Once you have a working Lazarus project you can work/build from within Lazarus or, if you prefer from the command line using a tool called lazbuild.

What you are doing right now is certainly possible but never will be easy, always will cause problems.

Davo

Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018