Lazarus

Using the Lazarus IDE => General => Topic started by: julkas on August 10, 2019, 11:28:33 am

Title: [SOLVED] Compile unit without project
Post by: julkas on August 10, 2019, 11:28:33 am
How compile standalone unit without project in Lazarus?
I got message - The project has no main source file.
Title: Re: Compile unit without project
Post by: Thaddy on August 10, 2019, 11:54:04 am
From the command line. (Or use Geany)
This bothers me too.
Title: Re: Compile unit without project
Post by: julkas on August 10, 2019, 01:02:42 pm
From the command line. (Or use Geany)
This bothers me too.
So what means Compile, Quick Compile in Lazarus menu?
What about Delphi?

BTW - I can compile unit in TP without main program (project) file.
Quote
The Compile | Compile command compiles only the file in the active edit window.
from the Turbo_Pascal_Version_7.0_Users_Guide_1992.pdf
Title: Re: Compile unit without project
Post by: valdir.marcos on August 10, 2019, 02:24:14 pm
From the command line. (Or use Geany)
This bothers me too.
So what means Compile, Quick Compile in Lazarus menu?
What about Delphi?
BTW - I can compile unit in TP without main program (project) file.
Lazarus IDE is project centric. It was designed that way.
You need to rethink and reimplement parts of the IDE to be able to open files without a project, or to compile files individually without a project or not related to the opened project.
Title: Re: Compile unit without project
Post by: julkas on August 10, 2019, 02:38:03 pm
Lazarus IDE is project centric. It was designed that way.
So it's project centric, not Pascal centric (program, unit, library)?
Title: Re: Compile unit without project
Post by: Thaddy on August 10, 2019, 02:48:31 pm
Lazarus IDE is project centric. It was designed that way.
You need to rethink and reimplement parts of the IDE to be able to open files without a project, or to compile files individually without a project or not related to the opened project.
Frankly, that will not do. That's why I use Geany for such cases. Btw: Delphi supports it, so why doesn't Lazarus.
Title: Re: Compile unit without project
Post by: julkas on August 10, 2019, 03:06:51 pm
Delphi supports it, so why doesn't Lazarus.
Simple logic.
Title: Re: Compile unit without project
Post by: julkas on August 10, 2019, 03:24:21 pm
Lazarus can and must support unit compilation without project.
Who have a different opinion?
Title: Re: Compile unit without project
Post by: Leledumbo on August 10, 2019, 11:24:36 pm
So what means Compile, Quick Compile in Lazarus menu?
https://wiki.lazarus.freepascal.org/index.php/Lazarus_Tutorial#Run
Lazarus IDE is project centric. It was designed that way.
So it's project centric, not Pascal centric (program, unit, library)?

A-a, different realm terms, don't mix it. Yes, the IDE can and have had support for projects written in other languages, but just as a text editor and project manager, probably with a little compiler integration and autocomplete support, everything else like the drag n drop functionality still only supports Pascal.
Lazarus can and must support unit compilation without project.
Who have a different opinion?
I'm not against nor support it. Good if it's there, but no problem if it's not there.
What's the occassion that you just want to compile a unit? Chance are, you compile it to use it somewhere, possibly in a program, which is managed by a project. BINGO! I guess that's how the project centric POV was born.
Title: Re: Compile unit without project
Post by: valdir.marcos on August 11, 2019, 09:09:19 am
Lazarus IDE is project centric. It was designed that way.
You need to rethink and reimplement parts of the IDE to be able to open files without a project, or to compile files individually without a project or not related to the opened project.
Frankly, that will not do. That's why I use Geany for such cases. Btw: Delphi supports it, so why doesn't Lazarus.
This is a Delphi's feature the community miss and complains about since 2005* and maybe even before.
I don't like this Lazarus' feature, but it doesn't bother me.
As a matter of fact, this is one of the rare cases where I think Lazarus should be similiar to Delphi instead of better.
I see, at least, two big problems here:
- People coming from Borland, Inprise, CodeGear, Embarcadero, Idera's products expect an intuitive behavior that doesn't exist on Lazarus and get lost for some time.
- Lazarus project lacks on manpower to study the case and provide a big patch to implement a solution. And once ready, that big patch could never be accepted because of its huge impact on IDE's source code...
So, I can't see any solution in a near future.


Lazarus 1.8.4 IDE/editor problems
https://forum.lazarus.freepascal.org/index.php/topic,44638.msg313983.html#msg313983

(1) "Close all" only closes, the (unit or text) files. The project stays open.

In Lazarus you always have to have a project open. (It just was designed that way a very long time ago, and to change it now would require rewrite of large parts of the IDE)

You can close the project from the project menu. But it will force you to open another project immediately (or close the IDE).

(2) Hence when you start Lazarus, either the last project can be re-opened, or an empty project has to be open.

(3) If you did "close all files" then the IDE may remember that no editor was open, so it will start a new project like this.
If you close a project with it's files open in the editor, then next time you open that project you should see editors right away.

(4) Not sure about 1.8.4, but in 2.0.0 (some of) those colors can be set.
On the color page for the editor, scroll down the tree with the color-elements. There is a section "Identifier Completion"


Compile LCL issue / error
https://forum.lazarus.freepascal.org/index.php/topic,29034.msg182687.html#msg182687

But, I'm not sure that it isn't related to the fact that I tried to compile "Transmission Remote GUI" before that, even tho' I did a "Close All" before trying the LCL Build.  Lazarus seems to "hold over" stuff from the previous project that was loaded.
No, File -> "Close All" does not close the project. It only closes files. That's why it is in Files menu. You still have the same project open.
The current project is closed when you open another project or create a new one. You can also do Project -> "Close Project" but then the IDE is not usable. That is because the session info is part of a project.

Having a project open always is a common complaint from new users. I believe you will complain about the same thing. :)
However it is a non-issue because the project can be a "virtual" project which is not saved anywhere. You can even run a virtual project, then it is automatically saved in a temp dir.

See the Project menu for project related actions, especially look at the project options.


lazarus GUI like Delphi 7 to 100%
https://forum.lazarus.freepascal.org/index.php?topic=22743.15

However you are not a new user. In what situation you need to explicitly close a project?
I have understood that a long time ago there was no dialog but it was added because many people wanted it.
I do close projects from time to time (though indeed rate). Typically if I make to many "recent files/project" jumps and I'm unsure about the project I have opened.

Speaking of history. Originally IDE didn't have many features out-side of the project scope. That's why there was not an option to close one.

Right now IDE has many options that could be addressed without having a project opened:
* packages (installation/removal);
* configuration of IDE itself and/or packages;
* some other tools in the system;

If I need to change FPC version or directory or select a new package to be installed, why would I have to click "New Project" -> "Application"? (just from the usability point of view?).

I'm tend to right all sorts of IDE extensions, as you know ;)
And IDE extension package cannot be a part of any project (as it doesn't really make sense), so I actually have to have something opened to continue editing the package.

IDE does allow to have a project opened without any source files opened.
So isn't it consistent to have IDE opened without any project opened?



* 2005: close projekt
https://forum.lazarus.freepascal.org/index.php?topic=807.0

2005: How about a Menuitem "Close Project" ?
https://forum.lazarus.freepascal.org/index.php?topic=1310.0

2006: How to close a project?
https://forum.lazarus.freepascal.org/index.php?topic=1850.0

2006: Closing a project.
https://forum.lazarus.freepascal.org/index.php/topic,2958.msg13597.html#msg13597

2008: 0012633: saves project file on Quit even after Close All Editor Files
https://bugs.freepascal.org/view.php?id=12633

2010: i can't close my program
https://forum.lazarus.freepascal.org/index.php?topic=10185.0

2015: Lazarus Release Candidate 1 of 1.4
https://forum.lazarus.freepascal.org/index.php/topic,27412.msg169569.html#msg169569

2015: Lazarus vs FPC
https://forum.lazarus.freepascal.org/index.php/topic,30347.msg193088.html#msg193088

2016: [SOLVED] Saved projects won't load
https://forum.lazarus.freepascal.org/index.php?topic=34004.0

2017: Lazarus Release Canditate 1 of 1.8
https://forum.lazarus.freepascal.org/index.php/topic,36907.msg246825.html#msg246825

2019: Source Editor not displaying
https://forum.lazarus.freepascal.org/index.php/topic,16715.msg307010.html#msg307010
Title: Re: Compile unit without project
Post by: valdir.marcos on August 11, 2019, 09:14:38 am
Delphi supports it, so why doesn't Lazarus.
Simple logic.
It's not that simple.
I myself think that Lazarus is much important that just being a Delphi's clone... Lazarus should be better than Delphi.
Title: Re: Compile unit without project
Post by: valdir.marcos on August 11, 2019, 09:18:27 am
Lazarus can and must support unit compilation without project.
Who have a different opinion?
Feel free to provide a patch and request the reopenig of bug report 12633:
0012633: saves project file on Quit even after Close All Editor Files
https://bugs.freepascal.org/view.php?id=12633
Title: Re: Compile unit without project
Post by: valdir.marcos on August 11, 2019, 09:35:24 am
Lazarus can and must support unit compilation without project.
Who have a different opinion?
You should avoid strong words as must on voluntary open source projects...

Lazarus can and must support unit compilation without project.
Who have a different opinion?
I'm not against nor support it. Good if it's there, but no problem if it's not there.
I tend to agree with you.

Quote
What's the occassion that you just want to compile a unit? Chance are, you compile it to use it somewhere, possibly in a program, which is managed by a project. BINGO! I guess that's how the project centric POV was born.
I'll just cite skalogryz's information:

However you are not a new user. In what situation you need to explicitly close a project?
I have understood that a long time ago there was no dialog but it was added because many people wanted it.
I do close projects from time to time (though indeed rate). Typically if I make to many "recent files/project" jumps and I'm unsure about the project I have opened.

Speaking of history. Originally IDE didn't have many features out-side of the project scope. That's why there was not an option to close one.

Right now IDE has many options that could be addressed without having a project opened:
* packages (installation/removal);
* configuration of IDE itself and/or packages;
* some other tools in the system;

If I need to change FPC version or directory or select a new package to be installed, why would I have to click "New Project" -> "Application"? (just from the usability point of view?).

I'm tend to right all sorts of IDE extensions, as you know ;)
And IDE extension package cannot be a part of any project (as it doesn't really make sense), so I actually have to have something opened to continue editing the package.

IDE does allow to have a project opened without any source files opened.
So isn't it consistent to have IDE opened without any project opened?
Title: Re: Compile unit without project
Post by: julkas on August 11, 2019, 10:58:09 am
Quote
You should avoid strong words as must on voluntary open source projects...
OK. May be my mistake.
I am Free Pascal beginner (some experience with TP7).
Quote
Turbo Pascal gives you several ways to create an executable
program or unit. You can
• Compile the current file with (Compile | Compile)
• Compile all changed files (Compile | Make)
• Compile all files in your project (Compile | Build)
• Compile and run your program (Run | Run)
Each of these options is suitable for a particular situation.
Title: Re: Compile unit without project
Post by: valdir.marcos on August 11, 2019, 12:12:03 pm
Quote
You should avoid strong words as must on voluntary open source projects...
OK. May be my mistake.
I am Free Pascal beginner (some experience with TP7).
Quote
Turbo Pascal gives you several ways to create an executable
program or unit. You can
• Compile the current file with (Compile | Compile)
• Compile all changed files (Compile | Make)
• Compile all files in your project (Compile | Build)
• Compile and run your program (Run | Run)
Each of these options is suitable for a particular situation.
Have you tried FP editor?
C:\lazarus\fpc\3.0.4\bin\i386-win32\fp.exe
Title: Re: Compile unit without project
Post by: julkas on August 11, 2019, 12:28:26 pm
Have you tried FP editor?
C:\lazarus\fpc\3.0.4\bin\i386-win32\fp.exe
Dir \lazarus\fpc\3.0.4\bin\i386-win32\  . Now on Win32 Vista Lazarus 2.0.0/FPC 3.0.4
Code: Text  [Select][+][-]
  1. 16/02/2019  03:32 μμ    <DIR>          .
  2. 16/02/2019  03:32 μμ    <DIR>          ..
  3. 07/04/2012  02:39 μμ           599.566 ar.exe
  4. 07/04/2012  02:39 μμ         1.028.110 as.exe
  5. 03/02/2019  02:14 πμ           199.680 bin2obj.exe
  6. 03/02/2019  02:13 πμ           453.632 chmcmd.exe
  7. 03/02/2019  02:13 πμ           254.976 chmls.exe
  8. 03/02/2019  02:14 πμ           666.624 cldrparser.exe
  9. 30/05/2005  09:05 μμ             6.144 cmp.exe
  10. 30/05/2005  09:05 μμ            22.528 cp.exe
  11. 30/05/2005  09:05 μμ            91.136 cpp.exe
  12. 03/02/2019  02:14 πμ            46.080 data2inc.exe
  13. 03/02/2019  02:14 πμ            98.816 delp.exe
  14. 30/05/2005  09:05 μμ            32.768 diff.exe
  15. 09/03/2011  12:17 μμ           689.664 dlltool.exe
  16. 27/05/2006  09:41 μμ             4.286 fp32.ico
  17. 16/02/2019  03:32 μμ             8.165 fpc.cfg
  18. 03/02/2019  02:14 πμ            95.744 fpc.exe
  19. 03/02/2019  02:14 πμ           262.144 fpcjres.exe
  20. 03/02/2019  02:14 πμ           474.624 fpclasschart.exe
  21. 03/02/2019  02:14 πμ           284.160 fpcmake.exe
  22. 03/02/2019  02:14 πμ           221.184 fpcmkcfg.exe
  23. 03/02/2019  02:14 πμ           327.168 fpcres.exe
  24. 03/02/2019  02:14 πμ           184.832 fpcsubst.exe
  25. 03/02/2019  02:14 πμ           838.656 fpdoc.exe
  26. 03/02/2019  02:14 πμ           181.248 fpmc.exe
  27. 03/02/2019  02:14 πμ           891.392 fppkg.exe
  28. 03/02/2019  02:14 πμ           186.880 fprcp.exe
  29. 30/05/2005  09:05 μμ            68.608 gcc.exe
  30. 30/05/2005  09:05 μμ            19.456 gdate.exe
  31. 30/05/2005  09:05 μμ             4.608 gecho.exe
  32. 30/05/2005  09:05 μμ            18.944 ginstall.exe
  33. 21/05/2009  11:36 πμ               388 ginstall.exe.manifest
  34. 30/05/2005  09:05 μμ            13.824 gmkdir.exe
  35. 30/05/2005  09:05 μμ            64.000 grep.exe
  36. 03/02/2019  02:14 πμ           307.200 h2pas.exe
  37. 03/02/2019  02:14 πμ            36.864 h2paspp.exe
  38. 03/02/2019  02:14 πμ           314.368 importtl.exe
  39. 03/02/2019  02:14 πμ           200.704 instantfpc.exe
  40. 07/04/2012  02:39 μμ           838.670 ld.exe
  41. 30/01/2011  09:43 μμ           165.513 libexpat-1.dll
  42. 10/05/2018  12:40 πμ           188.942 make.exe
  43. 03/02/2019  02:14 πμ           470.016 makeskel.exe
  44. 03/02/2019  02:14 πμ             2.248 makeskel.rsj
  45. 03/02/2019  02:14 πμ            39.936 mkarmins.exe
  46. 03/02/2019  02:14 πμ            47.104 mkinsadd.exe
  47. 03/02/2019  02:14 πμ            43.520 mkx86ins.exe
  48. 30/05/2005  09:05 μμ            31.744 mv.exe
  49. 07/04/2012  02:39 μμ           586.766 nm.exe
  50. 07/04/2012  02:39 μμ           726.030 objcopy.exe
  51. 07/04/2012  02:39 μμ         1.092.622 objdump.exe
  52. 03/02/2019  02:14 πμ           370.688 pas2fpm.exe
  53. 03/02/2019  02:14 πμ           413.184 pas2jni.exe
  54. 03/02/2019  02:14 πμ           373.248 pas2ut.exe
  55. 30/05/2005  09:05 μμ            28.160 patch.exe
  56. 21/01/2010  06:23 μμ               388 patch.exe.manifest
  57. 03/02/2019  02:14 πμ           120.832 plex.exe
  58. 03/02/2019  02:14 πμ            47.616 postw32.exe
  59. 03/02/2019  02:14 πμ         2.387.968 ppc386.exe
  60. 03/02/2019  02:14 πμ            40.960 ppdep.exe
  61. 03/02/2019  02:14 πμ           353.280 ppudump.exe
  62. 03/02/2019  02:14 πμ            95.232 ppufiles.exe
  63. 03/02/2019  02:14 πμ           109.568 ppumove.exe
  64. 03/02/2019  02:14 πμ           192.512 ptop.exe
  65. 03/02/2019  02:14 πμ               789 ptop.rsj
  66. 30/05/2005  09:05 μμ             2.560 pwd.exe
  67. 03/02/2019  02:14 πμ           136.192 pyacc.exe
  68. 30/05/2005  09:05 μμ            30.720 rm.exe
  69. 03/02/2019  02:14 πμ            89.600 rmcvsdir.exe
  70. 03/02/2019  02:14 πμ            51.712 rmwait.exe
  71. 03/02/2019  02:14 πμ           345.600 rstconv.exe
  72. 07/04/2012  02:39 μμ           726.030 strip.exe
  73. 03/02/2019  02:14 πμ           250.880 unihelper.exe
  74. 03/02/2019  02:14 πμ           371.200 unitdiff.exe
  75. 30/05/2005  09:05 μμ            41.472 unzip.exe
  76. 01/10/2011  11:34 μμ           662.542 windres.exe
  77. 30/05/2005  09:05 μμ           141.200 windres.h
  78. 25/02/2009  09:36 μμ             1.345 yylex.cod
  79. 25/02/2009  09:36 μμ             4.334 yyparse.cod
  80. 30/05/2005  09:05 μμ            32.256 zip.exe
  81.  
Title: Re: Compile unit without project
Post by: lucamar on August 11, 2019, 12:42:01 pm
Have you tried FP editor?
C:\lazarus\fpc\3.0.4\bin\i386-win32\fp.exe

Lazarus doesn't install FPC's IDE; one has to either build it from the source folder or install a separate FPC.
Title: Re: Compile unit without project
Post by: Martin_fr on August 11, 2019, 12:45:46 pm
How compile standalone unit without project in Lazarus?
I got message - The project has no main source file.

Afaik "Quick Compile" means to compile without linking (check project (or package) for syntax errors, but do not produce an exe).

You can configure an "external tool" that will call the compiler for the current editor file.

In any case the error message you get is a different issue. It means you somehow messed up your project.
As it was said, Lazarus is project orientated. The IDE will insist that there is always a (valid) project open. You may compile a single file from that project, but you must have a project open.
Many people believe that "FIle" > "Close All" will close the project, but it does not. It closes all source editors. But the project is still open.

The error you got is unusual. Normally the IDE creates a project with a main source file. I am not sure if there is a way to remove this.
The error does however happen, if you open a project that was created or saved by trunk (Lazarus 2.1) in an earlier version of Lazarus. This is because the file format changed. If you use both versions, then 2.1 has a setting to write compatible project files (project options > Miscellaneous: Maximize compatibility lps/lpi)
Title: Re: Compile unit without project
Post by: julkas on August 11, 2019, 12:54:03 pm
Have you tried FP editor?
C:\lazarus\fpc\3.0.4\bin\i386-win32\fp.exe

Lazarus doesn't install FPC's IDE; one has to either build it from the source folder or install a separate FPC.
You mean Windows default install?
Title: Re: Compile unit without project
Post by: julkas on August 11, 2019, 12:57:06 pm
You can configure an "external tool" that will call the compiler for the current editor file.
Can you give me simple example?
Title: Re: Compile unit without project
Post by: PascalDragon on August 11, 2019, 01:54:26 pm
Lazarus can and must support unit compilation without project.
Who have a different opinion?
I have. FPC's compilation speed is fast enough that it doesn't really matter whether I compile the whole program or a single unit (that in turn might depend on other units which will thus be compiled as well if they changed). And if I really need to keep some stuff precompiled then I use a Lazarus package. Also assures that it's recompiled should I change something in there. (Though "Compile package of current unit" instead of doing a complete compilation of the program might be useful, don't know if there is something like that already...)
So no, I'm not missing the ability to compile a single unit from within Lazarus and I also don't agree that it must support it.
Also I don't see Delphi supporting this. At least I couldn't find it in Delphi 10.2.
Title: Re: Compile unit without project
Post by: julkas on August 11, 2019, 02:23:50 pm
Lazarus can and must support unit compilation without project.
Who have a different opinion?
FPC's compilation speed is fast enough that it doesn't really matter whether I compile the whole program or a single unit
My question is not about compiler speed.
Lazarus can and must support unit compilation without project.
Who have a different opinion?
So no, I'm not missing the ability to compile a single unit from within Lazarus and I also don't agree that it must support it.
OK.
Lazarus can and must support unit compilation without project.
Who have a different opinion?
Also I don't see Delphi supporting this. At least I couldn't find it in Delphi 10.2.
Surprise. I don't have Delphi.
Title: Re: Compile unit without project
Post by: lucamar on August 11, 2019, 02:44:56 pm
You mean Windows default install?

Yes, the Windows install doesn't include the text-mode IDE.

In *nixes they are separate packages: a (more or less) standard fpc (and fpc-src) on one hand and Lazarus on the other, so the FPC package *does* include the FP IDE.
Title: Re: Compile unit without project
Post by: julkas on August 11, 2019, 02:54:17 pm
You mean Windows default install?

Yes, the Windows install doesn't include the text-mode IDE.

In *nixes they are separate packages: a (more or less) standard fpc (and fpc-src) on one hand and Lazarus on the other, so the FPC package *does* include the FP IDE.
Ya. I remember fp-ide on Linux install ...
Title: Re: Compile unit without project
Post by: Thaddy on August 11, 2019, 03:09:28 pm
You mean Windows default install?

Yes, the Windows install doesn't include the text-mode IDE.

In *nixes they are separate packages: a (more or less) standard fpc (and fpc-src) on one hand and Lazarus on the other, so the FPC package *does* include the FP IDE.

Since when? Because I always have it available. If you build fpc, fp.exe is also built.
Title: Re: Compile unit without project
Post by: Bart on August 11, 2019, 03:20:55 pm
The fpc installer on Windows AFAIK asks if you want to install the fp IDE...

Bart
Title: Re: Compile unit without project
Post by: lucamar on August 11, 2019, 03:23:48 pm
You mean Windows default install?

Yes, the Windows install doesn't include the text-mode IDE.

Since when? Because I always have it available. If you build fpc, fp.exe is also built.

Yes, if you build it. But the standard Lazarus installer (the EXE you download from SF or wherever) does NOT include a compiled text-mode IDE, just as it includes only the bare needed fpc souirces, rather than the full ones..

AFAIR, it has always been so.

The fpc installer on Windows AFAIK asks if you want to install the fp IDE...

The FPC one yes, but the Lazarus one doesn't. And has never done, AFAICT
Title: Re: Compile unit without project
Post by: Martin_fr on August 11, 2019, 04:28:42 pm
You can configure an "external tool" that will call the compiler for the current editor file.
Can you give me simple example?
Menu Tools > Configure External Tools
then "add"

It is pretty self explaining, name it, choose the fpc.exe as program, and add params $EdFile()

There may be more an the wiki, not sure, you can give it a search.
Title: Re: Compile unit without project
Post by: julkas on August 12, 2019, 09:18:34 am
You can configure an "external tool" that will call the compiler for the current editor file.
Can you give me simple example?
Menu Tools > Configure External Tools
then "add"

It is pretty self explaining, name it, choose the fpc.exe as program, and add params $EdFile()

There may be more an the wiki, not sure, you can give it a search.
Nice. Works.
Title: Re: Compile unit without project
Post by: Thaddy on August 12, 2019, 12:03:13 pm
Nice. Works.
Well it works, but it does not take into account the compiler settings you configured in the Lazarus IDE.
That may be not what you expect or want. You can also not debug.
Title: Re: Compile unit without project
Post by: julkas on August 12, 2019, 12:08:34 pm
Nice. Works.
Well it works, but it does not take into account the compiler settings you configured in the Lazarus IDE.
That may be not what you expect or want. You can also not debug.
I want only fpc $EdFile()
TinyPortal © 2005-2018