Recent

Author Topic: Alternative of DCU  (Read 6574 times)

Deepaak

  • Sr. Member
  • ****
  • Posts: 454
Alternative of DCU
« on: September 10, 2014, 09:24:57 pm »
What is the alternative of DCU (Delphi Compiled Unit)  in Lazarus/Freepascal.
Holiday season is online now. :-)

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Alternative of DCU
« Reply #1 on: September 10, 2014, 09:28:16 pm »
FPC compiled units have the extension .ppu

Deepaak

  • Sr. Member
  • ****
  • Posts: 454
Re: Alternative of DCU
« Reply #2 on: September 10, 2014, 09:48:59 pm »
FPC compiled units have the extension .ppu

can .ppu be used Lazarus/freepascal as the same way .dcu are used in delphi
Holiday season is online now. :-)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Alternative of DCU
« Reply #3 on: September 10, 2014, 10:16:41 pm »
can .ppu be used Lazarus/freepascal as the same way .dcu are used in delphi
no.
The pair of .ppu + .o file can replace Delphi's .dcu (this is how i.e. RTL / FCL and Lazarus "packages" are working)
.ppu on their own cannot.

Deepaak

  • Sr. Member
  • ****
  • Posts: 454
Re: Alternative of DCU
« Reply #4 on: September 10, 2014, 10:22:55 pm »
no.
The pair of .ppu + .o file can replace Delphi's .dcu (this is how i.e. RTL / FCL and Lazarus "packages" are working)
.ppu on their own cannot.

Is there any working example of how the pair of  .ppu  + .o file works in Lazarus.
Holiday season is online now. :-)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Alternative of DCU
« Reply #5 on: September 10, 2014, 10:54:17 pm »
Is there any working example of how the pair of  .ppu  + .o file works in Lazarus.
Sure.  Lazarus packages are the best example.

Do the following.
1. Start a new Lazarus Application project. You can open up the Project Inspector and see that the project requires LCL only.
2. Drop SynEdit control on the form. You can bring up the Project Inspect and see that now project requires SynEdit package as well.
3. Lazarus precompiles package (in order to be used by IDE as well as project compilation time boosts). Thus each package is used as a collection of .ppu and .o files
4. Look at compiler options (look at "Show Options" button) to see that a search path for SynEdit component units has been added.
This is done in order for compiler to find SynEdit .ppu and .o files (without using SynEdit .pas files).
Note, that FPC itself has no idea about Lazarus packages, that's why Lazarus adds the search path implicitly.
5. If you look at the folder that has been added to the units search path, you'll find .ppu and .o files there.

So at the point, Lazarus doesn't need to have access to SynEdit sources, just compile units to have the project compiled.
Similar to Delphi needs access to .dcu files only.

Lazarus however will ask for sources in order CodeTools to work, but it's only user experience and has nothing to do with compilation.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Alternative of DCU
« Reply #6 on: September 10, 2014, 11:55:29 pm »
@skalogryz
It would be good to have your clear .ppu/.o explanation and example in the wiki somewhere, making clear the distinction between the IDE/Codetools need for the sources (for code navigation, autocompletion etc.), and the compiler's need for paths to the pre-compiled object files.

Possibly also linked to the infamous "cannot find xxx" compiler message which is so misleading and confusing for new converts from Delphi who often have that very (Pascal source) file open in the editor, so wonder why it cannot be "found", and resort to adding Pascal source paths to the compiler options (a la Delphi) and compound their problems.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Alternative of DCU
« Reply #7 on: September 11, 2014, 04:49:20 am »
...but delphi works exactly the same!

One can open a delphi project and then open a unit that's not within project search path. Ending up with the exactly same "cannot find xxx" error.

The only confusion might comeup is then a project: library/component needs to be distributed (without sources). But whoever would try to do that... are already advanced enough to understand .ppu + .o = .dcu

Plus .ppu and .o are explained at FPC FAQ. Yes. rare people read it, but the wiki is rarely read too.

I'm still not sure about what exactly Deepaak is looking for.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Alternative of DCU
« Reply #8 on: September 11, 2014, 08:05:03 am »
FYI: see also
http://wiki.lazarus.freepascal.org/Lazarus_Packages#Creating_a_closed_sourced_package
where .ppu and .o files are also explained - though granted, in a slightly unexpected place.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

 

TinyPortal © 2005-2018