Recent

Author Topic: [SOLVED]HowToUseFPCOptions:-CroOti-v<x> -FU -FE for command line compiling (Win)  (Read 690 times)

DumboBell

  • New member
  • *
  • Posts: 7
Hey together,

I want to compile a hello world example as a test for debugging in some other directories.

I used try and error method, the google search a lot and the search function here in the forum, maybe I used the wrong key words.

Code: Pascal  [Select][+][-]
  1. {$R+}
  2. {$B+}
  3. program HelloWorld(output);
  4. uses Crt;
  5.  
  6. begin
  7.   WriteLn('Hello, World 2!');
  8.   ReadKey;
  9. end.

the directorie structure is like:
...\Pascal\example
...\Pascal\.build\debug

in the directory FreePascal\fppkg\config I found this default config:
Code: Text  [Select][+][-]
  1. [Defaults]
  2. ConfigVersion=5
  3. Compiler=C:\FPC\3.2.2\bin\i386-Win32\fpc.exe
  4. OS=Win32
  5. CPU=i386

I found this for a task example in vs code (https://stephan-bester.medium.com/free-pascal-in-visual-studio-code-e1e0a240a430)


Code: Text  [Select][+][-]
  1. "${PROJECTFILE}", // main project file
  2. "${PROCESSOR}", // target processor
  3. "${SYNTAX}", // pascal syntax mode
  4. "-CroOti", // generated code setting
  5. "-O-", // disable optimization
  6. "-g", // debug info
  7. "-B", // rebuild all units
  8. "-v", // verbose message
  9. "-gw", // dwarf debug setting
  10. "-godwarfsets", // dwarf mode setting
  11. "-FE${DEBUG}", // output for binary
  12. "-FU${OUTPUT}" // output for units

For a better understanding I looked at the options here:
Alphabetical listing of command line options:
https://www.freepascal.org/docs-html/user/userap1.html

Target processor and syntax I will leave it on default/not set for now.
  • -CroOti - I did not found anything about that. Could somebody tell me more about that?
  • -O-        Disable optimizations
  • -g     Generate debug information (default format for target)
  • -B     Build all modules
  • -v<x>  Be verbose. <x> is a combination of the following letters:  => show some information about the compiling?
  • -gw        Generate DWARFv2 debug information => make it possible for gdb debugging.
  • -godwarfsets  Enable DWARF 'set' type debug information (breaks gdb < 6.5)
  • -FE<x>     Set exe/unit output path to <x> => exe output to a special directory
  • -FU<x>     Set unit output path to <x>, overrides -FE => unit output to a special directory
I found this one a good Idea:
  • -Cr        Range checking

=>
Code: Text  [Select][+][-]
  1. fpc example\Test.pas -Co -CroOti -Cr -O- -g -B -v -gw -godwarfsets -FE .build\debug\ -FU .build\

Code: Text  [Select][+][-]
  1. Warning: Only one source file supported, changing source file to compile from "example\Test.pas" into ".build\debug\"
  2. Warning: Only one source file supported, changing source file to compile from ".build\debug\" into ".build\"
  3. Free Pascal Compiler version 3.2.2 [2021/05/15] for x86_64
  4. Copyright (c) 1993-2021 by Florian Klaempfl and others
  5. Target OS: Win64 for x64
  6. Compiling .build\\
  7. Fatal: Cannot open file ""
  8. Fatal: Compilation aborted
  9. Error: C:\FPC\3.2.2\bin\i386-Win32\ppcrossx64.exe returned an error exitcode

So I tried this with a simple break point set in the IDE:
Code: Text  [Select][+][-]
  1. fpc example\Test.pas -Co -CroOti -Cr -O- -g -B -v -gw -godwarfsets
=>
Code: Text  [Select][+][-]
  1. gdb example/Test.exe
=>
Code: Text  [Select][+][-]
  1. (gdb) break main
  2. Breakpoint 1 at 0x401679: Test.pas, line 7.
  3. (gdb) r
  4. Starting program: Test.exe
  5. [New Thread 32476.0x52ac]
  6. [New Thread 32476.0x24b4]
  7. [New Thread 32476.0xebc]
  8. [New Thread 32476.0x5510]
  9.  
  10. Breakpoint 1, main () at example/Test.pas:7
  11. 7         WriteLn('Hello, World 2!');
  12. (gdb) n
  13. Hello, World 2!
  14. 8         ReadKey;
  15. (gdb)
  16. 9       end.(gdb)
  17.  
  18. Program exited normally.
=>

I would use right now:
Code: Bash  [Select][+][-]
  1. fpc file -Co -Cr -O- -g -B -v -gw -godwarfsets

I want to understand what I'm doing wrong with -FE and -FU so it does not do what I'm expecting, and how I can achieve this in a powershell terminal.
If I would like to change the target processor to an 64 bit system and the dialekt like in the link I have some questions too:
-Px86_64 if I'm using this option gdb can't recognize it anymore and throw
Quote
...Test.exe": not in executable format: File format not recognized
, I would say gdb has some trouble with this kind of architecture (32 bit or 64 bit) I guess? => I need a different dgb installation?
If I would like to use -Mobjfpc. It is a Pascal dialect and does not effect anything yet correct? But I have to watch what kind of pascal dialect I will use in future programms?

my system is:
Quote
windows 11 pro - 64 bit version
powershell --version 7.3.3
fpc --version 3.2.2
gdb --version 7.2 (13.1 is released - I think I look how I can Update this maybe it will solve the issue above with -Px86_64...)

Best regards and thank you for your help

Edit: Some typos, and subject from "How to use fpc option -FU -FE for command line compiling" to "How to use fpc options: -CroOti -v<x> -FU -FE for command line compiling (Win)"
Edit: [SOLVED] Subject
« Last Edit: March 07, 2023, 10:39:45 pm by DumboBell »

Roland57

  • Sr. Member
  • ****
  • Posts: 421
    • msegui.net
Re: How to use fpc option -FU -FE for command line compiling
« Reply #1 on: March 05, 2023, 02:36:19 pm »
Hello (and welcome to the forum).

For the -FU and -FE options, the solution is to remove space:

Code: Text  [Select][+][-]
  1. -FE.build\debug\ -FU.build\
My projects are on Gitlab and on Codeberg.

DumboBell

  • New member
  • *
  • Posts: 7
Re: How to use fpc option -FU -FE for command line compiling
« Reply #2 on: March 05, 2023, 02:54:33 pm »
Hello and thank you for your welcome.

I tried your suggestion unfortunatly it failed:

Terminal Powershell:
Code: Text  [Select][+][-]
  1. fpc example\Test.pas -Co -Cr -O- -g -B -v -gw -godwarfsets -FE.build\debug\ -FU.build\
  2. Warning: Only one source file supported, changing source file to compile from "example\Test.pas" into ".build\debug\"
  3. Warning: Only one source file supported, changing source file to compile from ".build\debug\" into ".build\"
  4. Free Pascal Compiler version 3.2.2 [2021/05/15] for i386
  5. Copyright (c) 1993-2021 by Florian Klaempfl and others
  6. Target OS: Win32 for i386
  7. Compiling .build\
  8. Fatal: Cannot open file ""
  9. Fatal: Compilation aborted
  10. Error: C:\FPC\3.2.2\bin\i386-Win32\ppc386.exe returned an error exitcode

Edit highligt in codeblock and:
Line 2 and 3: "...changing source file to compile from..." this is something I would say is wrong. Because I want to put my files there and not as a source file to compile from.

I want to compile to this directory  %)
« Last Edit: March 05, 2023, 02:59:45 pm by DumboBell »

Roland57

  • Sr. Member
  • ****
  • Posts: 421
    • msegui.net
Re: How to use fpc option -FU -FE for command line compiling
« Reply #3 on: March 05, 2023, 03:04:01 pm »
Here (on Linux) the following command works:

Code: Text  [Select][+][-]
  1. [roland@localhost test]$ fpc example/Test.pas -FE.build/debug -FU.build
  2. Free Pascal Compiler version 3.2.0 [2020/07/05] for x86_64
  3. Copyright (c) 1993-2020 by Florian Klaempfl and others
  4. Target OS: Linux for x86-64
  5. Compiling example/Test.pas
  6. Linking .build/debug/Test
  7. 2 lines compiled, 0.1 sec
  8. [roland@localhost test]$

Maybe on Windows it doesn't work because of the "." in the directory name.
My projects are on Gitlab and on Codeberg.

Roland57

  • Sr. Member
  • ****
  • Posts: 421
    • msegui.net
Re: How to use fpc option -FU -FE for command line compiling
« Reply #4 on: March 05, 2023, 03:07:37 pm »
Maybe you could try -FE.\.build\debug (not sure).

Or just use a simple name for your directory.  :)
My projects are on Gitlab and on Codeberg.

DumboBell

  • New member
  • *
  • Posts: 7
Re: How to use fpc option -FU -FE for command line compiling
« Reply #5 on: March 05, 2023, 03:11:53 pm »
Maybe you could try -FE.\.build\debug (not sure).

Or just use a simple name for your directory.  :)

Edit:
I want to use . so the directory is marked as hidden, also on other systems, or what the convention exactly is there :)

The solution is:
Code: Text  [Select][+][-]
  1. -FE".build\debug\" -FU".build\"

Thank you very much.

Code: Text  [Select][+][-]
  1. \Pascal> fpc example\Test.pas -Co -Cr -O- -g -B -v -gw -godwarfsets -FE".build\debug\" -FU".build\"
  2. Free Pascal Compiler version 3.2.2 [2021/05/15] for i386
  3. Copyright (c) 1993-2021 by Florian Klaempfl and others
  4. Target OS: Win32 for i386
  5. Compiling example\Test.pas
  6. Linking .build\debug\Test.exe
  7. 8 lines compiled, 0.1 sec, 33248 bytes code, 1444 bytes data

Do you also can tell me something about this options?
Or I have to make a new Topic for each question?

-CroOti - I did not found anything about that. Could somebody tell me more about that?
-v<x>  Be verbose. <x> is a combination of the following letters:  => show some information about the compiling?
« Last Edit: March 05, 2023, 03:20:50 pm by DumboBell »

tetrastes

  • Sr. Member
  • ****
  • Posts: 473
Re: How to use fpc option -FU -FE for command line compiling
« Reply #6 on: March 05, 2023, 09:26:49 pm »
-CroOti - I did not found anything about that. Could somebody tell me more about that?
-v<x>  Be verbose. <x> is a combination of the following letters:  => show some information about the compiling?

-CroOti is the same as -Cr -Co -CO -Ct -Ci. What these options mean (and -v<x> also), you can find in manuals, to see briefly you can launch fpc without parameters.

DumboBell

  • New member
  • *
  • Posts: 7
Re: How to use fpc option -FU -FE for command line compiling
« Reply #7 on: March 07, 2023, 10:48:27 pm »
Thank you all for your answers, I got my settings now to work that way I expect it. d(^.^)b

-CroOti - I did not found anything about that. Could somebody tell me more about that?
-v<x>  Be verbose. <x> is a combination of the following letters:  => show some information about the compiling?

-CroOti is the same as -Cr -Co -CO -Ct -Ci. What these options mean (and -v<x> also), you can find in manuals, to see briefly you can launch fpc without parameters.

I searched for a manual, but I just wanted to be sure, that I understood it right and I was never finding -CroOti.

English is not my native language. ;)
So I ask one more question just to be sure.  :-[

=> so if somebody missed this link:

Quote
For a better understanding I looked at the options here:
Alphabetical listing of command line options:
https://www.freepascal.org/docs-html/user/userap1.html

 

TinyPortal © 2005-2018