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.
{$R+}
{$B+}
program HelloWorld(output);
uses Crt;
begin
WriteLn('Hello, World 2!');
ReadKey;
end.
the directorie structure is like:
...\Pascal\example
...\Pascal\.build\debug
in the directory FreePascal\fppkg\config I found this default config:
[Defaults]
ConfigVersion=5
Compiler=C:\FPC\3.2.2\bin\i386-Win32\fpc.exe
OS=Win32
CPU=i386
I found this for a task example in vs code (
https://stephan-bester.medium.com/free-pascal-in-visual-studio-code-e1e0a240a430)
"${PROJECTFILE}", // main project file
"${PROCESSOR}", // target processor
"${SYNTAX}", // pascal syntax mode
"-CroOti", // generated code setting
"-O-", // disable optimization
"-g", // debug info
"-B", // rebuild all units
"-v", // verbose message
"-gw", // dwarf debug setting
"-godwarfsets", // dwarf mode setting
"-FE${DEBUG}", // output for binary
"-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.htmlTarget 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:
=>
fpc example\Test.pas -Co -CroOti -Cr -O- -g -B -v -gw -godwarfsets -FE .build\debug\ -FU .build\
Warning: Only one source file supported, changing source file to compile from "example\Test.pas" into ".build\debug\"
Warning: Only one source file supported, changing source file to compile from ".build\debug\" into ".build\"
Free Pascal Compiler version 3.2.2 [2021/05/15] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Win64 for x64
Compiling .build\\
Fatal: Cannot open file ""
Fatal: Compilation aborted
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:
fpc example\Test.pas -Co -CroOti -Cr -O- -g -B -v -gw -godwarfsets
=>
=>
(gdb) break main
Breakpoint 1 at 0x401679: Test.pas, line 7.
(gdb) r
Starting program: Test.exe
[New Thread 32476.0x52ac]
[New Thread 32476.0x24b4]
[New Thread 32476.0xebc]
[New Thread 32476.0x5510]
Breakpoint 1, main () at example/Test.pas:7
7 WriteLn('Hello, World 2!');
(gdb) n
Hello, World 2!
8 ReadKey;
(gdb)
9 end.(gdb)
Program exited normally.
=>
I would use right now:
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
...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:
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