Recent

Author Topic: Fpc command line parameters in Lazarus for different platforms  (Read 3041 times)

simone

  • Hero Member
  • *****
  • Posts: 573
Dear all, I need to call fpc compiler from my code generator, in order to compile
generated code in 'release mode' for both console and GUI application, 32/64 bits.
In Lazarus, using 'Project Inspector'->'Show Options' I can see default command line
parameters for my development platform (Windows).

I need to call fpc in a cross platform way. Could someone be so kind to give me the
parameters under Linux and Mac OS X?

Thanks in advance.
Microsoft Windows 10 64 bit - Lazarus 3.0 FPC 3.2.2 x86_64-win64-win32/win64

Thaddy

  • Hero Member
  • *****
  • Posts: 14201
  • Probably until I exterminate Putin.
Re: Fpc command line parameters in Lazarus for different platforms
« Reply #1 on: April 25, 2019, 12:20:08 pm »
fpc -dRELEASE
Specialize a type, not a var.

simone

  • Hero Member
  • *****
  • Posts: 573
Re: Fpc command line parameters in Lazarus for different platforms
« Reply #2 on: April 25, 2019, 01:12:44 pm »
Thanks Thaddy. I know that in this way the symbol RELEASE is defined. My question is about command line parameters for fpc used by Lazarus to compile console/GUI app in Linux / Mac. 

In other words, under Windows 64 bit (GUI app, release mode), Lazarus uses the following default parameters:

{LazarusBaseDir}\fpc\3.0.4\bin\x86_64-win64\fpc.exe
-MObjFPC
-Scghi
-CX
-O3
-XX
-WG
-l
-vewnhibq
-Fi{OutputDir}\lib\x86_64-win64
-Fu{LazarusBaseDir}\lcl\units\x86_64-win64\win32
-Fu{LazarusBaseDir}\lcl\units\x86_64-win64
-Fu{LazarusBaseDir}\components\lazutils\lib\x86_64-win64
-Fu{LazarusBaseDir}\packager\units\x86_64-win64
-Fu{OutputDir}
-FU{OutputDir}\lib\x86_64-win64\
-FE{OutputDir}
-o{OutputDir}FileName.exe
-dLCL
-dLCLwin32

What are the line parameters on the other platforms?
Microsoft Windows 10 64 bit - Lazarus 3.0 FPC 3.2.2 x86_64-win64-win32/win64

Thausand

  • Sr. Member
  • ****
  • Posts: 292
Re: Fpc command line parameters in Lazarus for different platforms
« Reply #3 on: April 25, 2019, 01:25:39 pm »
In other words, under Windows 64 bit (GUI app, release mode), Lazarus uses the following default parameters:
many is same default if cross-compile

Quote
-MObjFPC
-Scghi
-CX
-O3
-XX
-WG
-l
-vewnhibq
That default most platform.

Quote
-Fi{OutputDir}\lib\x86_64-win64
-Fu{LazarusBaseDir}\lcl\units\x86_64-win64\win32
-Fu{LazarusBaseDir}\lcl\units\x86_64-win64
-Fu{LazarusBaseDir}\components\lazutils\lib\x86_64-win64
-Fu{LazarusBaseDir}\packager\units\x86_64-win64
-Fu{OutputDir}
-FU{OutputDir}\lib\x86_64-win64\
-FE{OutputDir}
-o{OutputDir}FileName.exe
-dLCL
-dLCLwin32

What are the line parameters on the other platforms?
here some is differ. But that strange configuration. FPC have better macro
Code: [Select]
Fu/../../bin/fpc/$FPCVERSION/units/$fpctarget/$fpcsubarch-$fpcmemorymodel
That make away hardcode target. fpc.cfg have special macro IFDEF for some platform and if cross-compile. Maybe look there for example ?

Quote
-o{OutputDir}FileName.exe
-dLCL
-dLCLwin32
That depend target widget and target default filename/extention. I think you make hardcode -o option ?

add:
Sorry i forget write. LazarusBaseDir is lazarus and no freepascal. I think alone lazbuild can understand ?
« Last Edit: April 25, 2019, 01:32:12 pm by Thausand »

simone

  • Hero Member
  • *****
  • Posts: 573
Re: Fpc command line parameters in Lazarus for different platforms
« Reply #4 on: April 25, 2019, 02:05:02 pm »
Thanks. I reported command line used by current Lazarus version on Windows 64 bits. LazarusBaseDir is needed to locate LCL, used by GUI app.

I know that there are many things platform dependent (widgets, path syntax of file system, executable name conventions etc).

I'd like to write a cross platform procedure, using conditional compilation, that run fpc to compile GUI application, but I undestand that, due to above reasons, it is not a trivial task.   
Microsoft Windows 10 64 bit - Lazarus 3.0 FPC 3.2.2 x86_64-win64-win32/win64

Thausand

  • Sr. Member
  • ****
  • Posts: 292
Re: Fpc command line parameters in Lazarus for different platforms
« Reply #5 on: April 25, 2019, 02:22:13 pm »
Can make Freepascal compile lazarus. That difficult because lazarus many use defines and macro and no have freepascal.

Example define outputdir is not freepascal and have make freepascal tricky. That why lazbuild more easy because can read and process project file lazarus.

I write note that is no default options any target. Default options is lazarus project and programmer make default. If cross compile then use same options but programmer can write other default options depend target. Lazarus have special project option window for make that.

Is possible compile lazarus use freepascal and no easy. Many work :)

If want see then make cross-compile project use lazarus and can see options  :D

I write other example. i read "-dLCLwin32" but that no default. What if want gtk windows ? If user have windows gtk install then can work also. Now you make hardcode use win32. Maybe ok for you project but may be not for any  one. That make difficult have default option. And what do target windows arm ? Then is wrong "x86_64-win64"

May be you try and see what make difficult ? Make many small step  :)

simone

  • Hero Member
  • *****
  • Posts: 573
Re: Fpc command line parameters in Lazarus for different platforms
« Reply #6 on: April 25, 2019, 04:22:16 pm »
May be the simplest solution for me is to call lazbuild wrapper for compile GUI applications (i.e. applications that require LCL) on different platform. However I noticed that if I use lazbuild to compile a simple console program, I get 'lazbuild don't know how to build'...     
Microsoft Windows 10 64 bit - Lazarus 3.0 FPC 3.2.2 x86_64-win64-win32/win64

Thausand

  • Sr. Member
  • ****
  • Posts: 292
Re: Fpc command line parameters in Lazarus for different platforms
« Reply #7 on: April 25, 2019, 04:31:54 pm »
I have not try lazbuild for console freepascal program and no project Lazarus. I try but not now. Maybe error because no have lazarus project file ?

Have make console program use Lazarus and have lazarus project file then use lazbuild ?

If true then maybe more easy a) have two way (1 fpc.exe 2 lazbuild.exe) or b) make wrapper create lazarus project file if console freepascal and use lazbuild.exe ?

simone

  • Hero Member
  • *****
  • Posts: 573
Re: Fpc command line parameters in Lazarus for different platforms
« Reply #8 on: April 25, 2019, 04:41:53 pm »
Yes, the console program is a simple .pas file, without .lpi project file. Peraphs I should use fpc (with default options) for console and lazbuild for GUI app. 
Microsoft Windows 10 64 bit - Lazarus 3.0 FPC 3.2.2 x86_64-win64-win32/win64

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Fpc command line parameters in Lazarus for different platforms
« Reply #9 on: April 25, 2019, 06:51:39 pm »
Yes, the console program is a simple .pas file, without .lpi project file. Peraphs I should use fpc (with default options) for console and lazbuild for GUI app.

I have found, to my chagrin, that lazbuild requires that you give it the full name of an .LPI file; v.g.
    lazbuild -B project1.lpi
It doesn't accept any other thing, contrary to what one may infer by a quick eye-grepping of its source.

Re. getting the command line for diverse platforms, you could just switch your target platform/cpu in lazarus and copy the command line. Lather, rinse and repeat until you're done :)
« Last Edit: April 25, 2019, 06:53:50 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

ASBzone

  • Hero Member
  • *****
  • Posts: 678
  • Automation leads to relaxation...
    • Free Console Utilities for Windows (and a few for Linux) from BrainWaveCC
Re: Fpc command line parameters in Lazarus for different platforms
« Reply #10 on: April 25, 2019, 07:16:20 pm »
Dear all, I need to call fpc compiler from my code generator, in order to compile
generated code in 'release mode' for both console and GUI application, 32/64 bits.
In Lazarus, using 'Project Inspector'->'Show Options' I can see default command line
parameters for my development platform (Windows).

I need to call fpc in a cross platform way. Could someone be so kind to give me the
parameters under Linux and Mac OS X?

Thanks in advance.


It seems to me that you might be able to use "Build Modes" to set all the options you want for each target, and then cycle through them and copy the appropriate command line parameters.

https://forum.lazarus.freepascal.org/index.php?topic=13357.0

http://wiki.lazarus.freepascal.org/IDE_Window:_Compiler_Options#Types_of_build_options

-ASB: https://www.BrainWaveCC.com/

Lazarus v2.2.7-ada7a90186 / FPC v3.2.3-706-gaadb53e72c
(Windows 64-bit install w/Win32 and Linux/Arm cross-compiles via FpcUpDeluxe on both instances)

My Systems: Windows 10/11 Pro x64 (Current)

simone

  • Hero Member
  • *****
  • Posts: 573
Re: Fpc command line parameters in Lazarus for different platforms
« Reply #11 on: April 25, 2019, 08:32:42 pm »
Thanks for valuable suggestions. A last thing about .lpi files: although I understood their simple XML structure, does a specification document exist for them?
Microsoft Windows 10 64 bit - Lazarus 3.0 FPC 3.2.2 x86_64-win64-win32/win64

simone

  • Hero Member
  • *****
  • Posts: 573
Re: Fpc command line parameters in Lazarus for different platforms
« Reply #12 on: April 25, 2019, 11:49:13 pm »
I started a new thread for this topic. Thanks for help.
Microsoft Windows 10 64 bit - Lazarus 3.0 FPC 3.2.2 x86_64-win64-win32/win64

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Fpc command line parameters in Lazarus for different platforms
« Reply #13 on: April 26, 2019, 01:30:14 am »

It seems to me that you might be able to use "Build Modes" to set all the options you want for each target, and then cycle through them and copy the appropriate command line parameters.

https://forum.lazarus.freepascal.org/index.php?topic=13357.0

http://wiki.lazarus.freepascal.org/IDE_Window:_Compiler_Options#Types_of_build_options

Yes, I recommend ASBzone's model, that how I build release and even final test versions of tomboy-ng.

I have a quite large set of build modes, windows, Linux, HeapTrc and not, so, 8 (plus one not used for releasing...).

Then a bash script that builds as required, bundle them up into debs and a dir ready for making window installers. Its not pretty, has blocks like this -
Code: [Select]
echo "Building x86_64 Linux"
rm tomboy-ng
if [ "$LEAKCHECK" == "YES" ]; then
LAZMODE="LeakCheckLin64"
else
LAZMODE="Release"
fi
TOMBOY_NG_VER="$VERSION" $LAZ_FULL_DIR/lazbuild $BUILDOPTS --pcp=~/."$LAZ_DIR" --cpu="x86_64" --build-mode="$LAZMODE" --os="linux" Tomboy_NG.lpi

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