Recent

Author Topic: [SOLVED]: Using Lazarus units without the use of Lazarus IDE/CLI tools  (Read 717 times)

Bogen85

  • Hero Member
  • *****
  • Posts: 595
EDIT: This topic/thread was split off from https://forum.lazarus.freepascal.org/index.php/topic,62150.0.html

This topic/thread is about using lazutils and associated units in FPC projects that are not managed by any FPC or Lazarus build or project tool.

Now that I found I can wrap their use in my own projects so I don't have to back off on my compiler flags for my own units, I plan to start using them more.
Why do you need a wrapper? The package .lpk file is understood only by Lazarus IDE but you should be able to use the units directly.

I don't use the Lazarus IDE or command line tools for development (apart from what I need for JCF command line and to occasionally build CudaText).
So my FPC projects are ones I just handle with GNU Makefiles.

When I use FPC units I don't get warning/notes/hints that cause the compilation to stop with what I have my compile flags set to.
As such I have to create wrapper units to disable the specific (or all) warnings/notes/hints so I can use LazUtils an associated units.

For FPC projects I've been content with using GNU make and have not any issue using any FPC related Unit, or FCL units, and would prefer not to have to anything beyond how I'm currently working with FPC in order to use Lazarus non GUI units.

I say prefer but I might consider better tooling (which is relative and subjective) if it truly gives me an advantage over my current usage of FPC, which I've not found to be deficient (for me at least).

« Last Edit: February 07, 2023, 03:48:24 am by Bogen85 »

Bogen85

  • Hero Member
  • *****
  • Posts: 595
Re: Using Lazarus units without the use of Lazarus IDE/CLI tools
« Reply #1 on: February 05, 2023, 03:53:29 pm »
With the wrappers I can use lazutils and related units. The wrappers are only needed because I'm not going to back off on my compile flags.
« Last Edit: February 07, 2023, 12:13:22 am by Bogen85 »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4458
  • I like bugs.
Re: Using Lazarus units with the use use of Lazarus IDE or command line tools
« Reply #2 on: February 05, 2023, 04:36:02 pm »
With the wrappers I can use lazutils and related units. The wrappers are only needed because I'm not going to back off on my compile flags.
I don't fully understand. What is wrong in adding a "Other unit files" (-Fu) path for the compiler?
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Bogen85

  • Hero Member
  • *****
  • Posts: 595
Re: Using Lazarus units without the use of Lazarus IDE/CLI tools
« Reply #3 on: February 05, 2023, 04:45:42 pm »
With the wrappers I can use lazutils and related units. The wrappers are only needed because I'm not going to back off on my compile flags.
I don't fully understand. What is wrong in adding a "Other unit files" (-Fu) path for the compiler?

Adding '-Fu' is not the issue. That works fine.
The issue is when I use the lazarus units (and not when I use RTL/FCL units) is that get messages about things not being initialized, parameters not being used, and so forth which cause compilation to abort, which for my own stuff I want so I can correct my code.
As I said, I don't need to do that with RTL/FCL units, I don't get the warnings/notes/hints issued for them when I use them.

Putting the push/suppressions/use unit/pop in the uses clause around individual units does not work correctly, hence a wrapper like the following in my own units folder earlier in the search path:

Code: Pascal  [Select][+][-]
  1. // lazutf8.pp
  2. {$push}
  3. {$warnings off}
  4. {$hints off}
  5. {$notes off}
  6. {$include lazutf8.pas}
  7. {$pop}

Any units are by lazutf8 or whatever other unit I'm doing that with are covered by those directives, so the compilation does not abort on them.

Like I said, using RTL/FCL units the compilation is not aborted, and when using my own units, I correct the faults in my own code to get them to compile and be used.

« Last Edit: February 07, 2023, 01:01:18 am by Bogen85 »

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: Using Lazarus units with the use use of Lazarus IDE or command line tools
« Reply #4 on: February 06, 2023, 10:30:51 pm »
The issue is when I use the lazarus units (and not when I use FPC/FCL units) is that get messages about things not being initialized, parameters not being used, and so forth which cause compilation to abort, which for my own stuff I want so I can correct my code.

Ever noticed that you get all those when compiling the LCL from within the IDE as well?

As I said, I don't need to do that with FPC/FCL units, I don't get the warnings/notes/hints issued for them when I use them.

The RTL/FCL units are precompiled, thus they are not compiled when you use them and thus there won't be such hints or warnings,  because they only happen when you compile the source files. For Lazarus you need to pass the lib/<cpu>-<os> directories that are created when compiling the packages to the -Fu<x> parameters instead of the source directories.

Bogen85

  • Hero Member
  • *****
  • Posts: 595
[SOLVED] Using Lazarus units without the use of Lazarus IDE/CLI tools
« Reply #5 on: February 07, 2023, 12:20:16 am »
The issue is when I use the lazarus units (and not when I use FPC/FCL units) is that get messages about things not being initialized, parameters not being used, and so forth which cause compilation to abort, which for my own stuff I want so I can correct my code.

Ever noticed that you get all those when compiling the LCL from within the IDE as well?

Yes. (Well, Not within the IDE, but with make bigide)

As I said, I don't need to do that with FPC/FCL units, I don't get the warnings/notes/hints issued for them when I use them.

The RTL/FCL units are precompiled, thus they are not compiled when you use them and thus there won't be such hints or warnings,  because they only happen when you compile the source files. For Lazarus you need to pass the lib/<cpu>-<os> directories that are created when compiling the packages to the -Fu<x> parameters instead of the source directories.

Thanks, that works!
I changed the -Fu<x> parameters to point the corresponding lib/<cpu>-<os> directories and now I do not need to use the wrapper units.

What I ran into was when I use RTL/FCL units those -Fu<x> parameters are already set correctly, but when I was using Lazarus units and had to set it myself, I was not setting them correctly.
« Last Edit: February 07, 2023, 02:09:21 pm by Bogen85 »

 

TinyPortal © 2005-2018