Recent

Author Topic: Compiling from the command-line  (Read 2785 times)

Raul_ES

  • Full Member
  • ***
  • Posts: 183
  • My interests: Healthcare & Computers
    • My Linkedin Profile, you can add me to stay in contact.
Compiling from the command-line
« on: October 24, 2017, 10:24:32 pm »
Hi,

sorry for the extreme-dummy question but I need some advice: the fpc compiler has an inmense variety of command line options  that aren't obvious to use, at least for a beginner like me. Please, there's any Quick-Guide or such for managing the compiler correctly? Is there any gcc to fpc guide?



To start with, how do I manually compile a pas file from the command line?

how do I  create a .so or dll library from the command line?

How shall I use the linker?

How I dinamicaly link a library? and statically?

How do I compile a project with multiple units in it?


thanks,
Pharmacy + Chemistry + Biology + Healthcare + Computing

If you have any interest or project related with these areas feel free to contact me!

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11452
  • FPC developer.
Re: Compiling from the command-line
« Reply #1 on: October 24, 2017, 10:31:51 pm »
sorry for the extreme-dummy question but I need some advice: the fpc compiler has an inmense variety of command line options  that aren't obvious to use, at least for a beginner like me. Please, there's any Quick-Guide or such for managing the compiler correctly? Is there any gcc to fpc guide?

fpc -? shows help and waits for each screen, fpc -h just goes on without asking for results (for pipe operation)

Lazarus also has commandline parameters (like -Sd -S2 for the compiler dialect modes) in its compiler options dialogue.

In general you need dialect options (-Sd,-S2),  directory options (-Fu, Fi), the command equivalent of $define (-dXXXX)  and debug/smartlinking options  (-g, -gl,-gw, -CX -XXs) the most.

I suggest you look into those first.

Quote
To start with, how do I manually compile a pas file from the command line?

fpc  filename   (with or without .pas extension)

The default dialect is "fpc", pass parameters (e.g. -Sd for Delphi mode) or add {$mode statements to the source.

Quote
how do I  create a .so or dll library from the command line?

Generally the same. The contents of the main file (program, or library) determines if it is an executable or  library

Quote
How shall I use the linker?

In general this is automatic. There are ways to bypass FPC and pass extra parameters.

Quote
How I dinamicaly link a library? and statically?

$linklib the libraryname in the source. The compiler should generally link whatever it finds with that name.

Quote
How do I compile a project with multiple units in it?

FPC finds its own files. Just pass the main module and directory options.

Raul_ES

  • Full Member
  • ***
  • Posts: 183
  • My interests: Healthcare & Computers
    • My Linkedin Profile, you can add me to stay in contact.
Re: Compiling from the command-line
« Reply #2 on: October 27, 2017, 06:03:51 pm »
Thank you marcov!
Pharmacy + Chemistry + Biology + Healthcare + Computing

If you have any interest or project related with these areas feel free to contact me!

 

TinyPortal © 2005-2018