TMainMenu not showing lazarus / 31-LCL ---------------------------------------------------------------------- shock · 2024-10-21 22:07 Hi.  Please be patient because I am new to Lazarus, but not to Delphi.  I have over a few years been converting a number of (command line) programs to FreePascal.  That has gone smoothly.  One of those programs uses VCL (now LCL) to run a couple of tests which plot graphics on a form.  The form uses a TMainMenu with a menu item for each test.  My problem is that the main menu is not shown.  I have searched for a day and am unable to work out what I have done wrong.  I can add other controls, such as a TButton, and they appear on the form. I run Linux Mint 21.3 x86_64, Cinnamon 6.0.4, Lazarus 3.6, FPC 3.2.2, x86_64_linux-gtk2.  FPC and Lazarus were downloaded and installed again yesterday, to make sure I had the latest versions. Note that I do *not* use the Lazarus or FreePascal IDEs.  I attach a severely trimmed program which shows, at least on my computer, the problem: the button is shown but not the main menu.  If I go the normal way of using the Lazarus IDE the main menu is shown, but I need all this to happen automatically using the command line and custom make files. Any help will be appreciated. Thank you. ---------------------------------------------------------------------- jamie · 2024-10-21 22:45 I didn't look at your app because I am on Windows. But, did you put the TApplication in as the main GUI from end and did you use the CreateForm to greate the forms? ---------------------------------------------------------------------- Aruna · 2024-10-21 23:30 Quote from: shock on October 22, 2024, 12:07:03 am but I need all this to happen automatically using the command line and custom make files. Any help will be appreciated. Hello, what is your command line @shock? Does it even vaguely resemble this:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fpc -MObjFPC -Scghi -O1 -vewnhi -l -dLCL -dLCLGtk2 -Fu/home/aruna/lazarus3/lazarus/lcl/units/x86_64-linux/gtk2 -Fu/home/aruna/lazarus3/lazarus/packager/units/x86_64-linux WSLCL.pas I tried to build your zip I managed to get some progress but now trying to resolve this error: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Free Pascal Compiler version 3.2.2 [2021/07/09] for x86_64Copyright (c) 1993-2021 by Florian Klaempfl and othersTarget OS: Linux for x86-64Compiling WSLCL.pasFatal: Can't find unit LMessages used by Gtk2IntFatal: Compilation abortedError: /usr/bin/ppcx64 returned an error exitcode So I am curious what command and flags you used when compiling, this is the reason I asked. ---------------------------------------------------------------------- JuhaManninen · 2024-10-22 00:08 Indeed you did not mention how you compiled it. You must create a Lazarus project with LCL dependency. Then you can build it with the command line LazBuild. ---------------------------------------------------------------------- Aruna · 2024-10-22 01:21 Quote from: JuhaManninen on October 22, 2024, 02:08:34 amIndeed you did not mention how you compiled it. You must create a Lazarus project with LCL dependency. Then you can build it with the command line LazBuild. Hello Juha, so if I use LazBuild I do not have to worry about any dependencies? LazBuild will pull in everything that is needed? I also just noticed in the OP's code he is assigning at first : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  test_Menu_Item_1.OnClick := Run_Test_1; And later on to: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i test_Menu_Item_1.OnClick := Run_Test_2; Which to me does not make sense?? ---------------------------------------------------------------------- TRon · 2024-10-22 03:31 Quote from: shock on October 22, 2024, 12:07:03 amMy problem is that the main menu is not shown. Add the following lines after you created the individual item(s): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   test_main_Menu.Items.Add(test_Menu_Item_1);  test_main_Menu.Items.Add(test_Menu_Item_2); ---------------------------------------------------------------------- TRon · 2024-10-22 03:42 Quote from: JuhaManninen on October 22, 2024, 02:08:34 amIndeed you did not mention how you compiled it. TS provided a fpc.cfg which kinda removes the requirement to mention it. small snippet: Code: [Select]-Fu/usr/share/lazarus/3.6.0/lcl/units/$fpctarget -Fu/usr/share/lazarus/3.6.0/lcl/units/$fpctarget/* -Fu/usr/share/lazarus/3.6.0/lcl/units/$fpctarget/gtk2 -Fu/usr/share/lazarus/3.6.0/components/lazutils/lib/$fpctarget QuoteYou must create a Lazarus project with LCL dependency. Then you can build it with the command line LazBuild. Whenever I read the word must then I think to myself, really ? and how can we do without ?  Turns out, pretty easy as long as you know what you are doing (and yes, I also get stuck with FPC attempting to compile packages with the command-line compiler because that can be a rats nest with all its dependencies = use lazbuild). ---------------------------------------------------------------------- Aruna · 2024-10-22 14:10 Quote from: TRon on October 22, 2024, 05:42:57 amTurns out, pretty easy as long as you know what you are doing (and yes, I also get stuck with FPC attempting to compile packages with the command-line compiler because that can be a rats nest with all its dependencies = use lazbuild). Hi TRon I have never used LazBuild before this is my first time and it chokes with: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i aruna@debian:~/lazarus/forum-demos/shock/test$ lazbuild --verbose WSLCL.pasError: (lazbuild) don't know how to build: /home/aruna/lazarus/forum-demos/shock/test/WSLCL.pas ---------------------------------------------------------------------- TRon · 2024-10-22 14:20 Quote from: Aruna on October 22, 2024, 04:10:02 pmHi TRon I have never used LazBuild before this is my first time and it chokes with: Lazbuild requires a lazarus project information file (.lpi) or Lazarus PacKage (.lpk) file to be able to build a Lazarus program/package. TS wrote a (pure) pascal program without providing a .lpi file. In such a program it is possible to create LCL classes at runtime but doing so manually. For instance, for TS it is not possible in his current situation to make use of f.e. the .lfm file (Lazarus ForM).(though in practice you can stream the lfm manually if you want to do so). See also lazbuild wiki and file extensions wiki ---------------------------------------------------------------------- JuhaManninen · 2024-10-22 14:47 Quote from: Aruna on October 22, 2024, 03:21:17 amHello Juha, so if I use LazBuild I do not have to worry about any dependencies? LazBuild will pull in everything that is needed? As explained by TRon, you need a Lazarus project. A dependency for LCL package there is enough. LazBuild takes care of the rest. Quote from: TRon on October 22, 2024, 05:42:57 amTS provided a fpc.cfg which kinda removes the requirement to mention it. I tried this: Code: [Select]$ fpc test_WSLCL.pas Free Pascal Compiler version 3.2.2 [2024/05/01] for x86_64 Copyright (c) 1993-2021 by Florian Klaempfl and others Target OS: Linux for x86-64 Compiling test_WSLCL.pas Compiling WSLCL.pas WSLCL.pas(8,17) Fatal: Can't find unit Interfaces used by WSLCL Fatal: Compilation aborted Error: /usr/bin/ppcx64 returned an error exitcode I confess I very seldom run fpc directly. I use Lazarus IDE and LazBuild as a middleman. ---------------------------------------------------------------------- TRon · 2024-10-22 15:31 Quote from: JuhaManninen on October 22, 2024, 04:47:43 pmI tried this: ... That is why TS provided his fpc.cfg. If FPC is not configured to locate the LCL then it can't find it unless the paths are manually provided, e.g. relevant part: Code: [Select]-Fu/usr/share/lazarus/3.6.0/lcl/units/$fpctarget -Fu/usr/share/lazarus/3.6.0/lcl/units/$fpctarget/* -Fu/usr/share/lazarus/3.6.0/lcl/units/$fpctarget/gtk2 -Fu/usr/share/lazarus/3.6.0/components/lazutils/lib/$fpctarget can be provided on the commandline: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fpc -B -Fu/usr/share/lazarus/3.6.0/lcl/units/$fpctarget -Fu/usr/share/lazarus/3.6.0/lcl/units/$fpctarget/gtk2 -Fu/usr/share/lazarus/3.6.0/components/lazutils/lib/$fpctarget test_WSLCL.pasAlthough when provided on the command-line and most probably depending on the used shell/terminal the dollar sign should be escaped properly. Personally I use an additional fpc.cfg file (that has these LCL paths declared) that is included in the main fpc.cfg file when a specific define is present to indicate that I want to use FPC to compile something that depends on the LCL so that I can do something like: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fpc -B -d"THIS_PROGRAM_REQUIRES_LCL" test_WSLCL.pas ---------------------------------------------------------------------- JuhaManninen · 2024-10-22 23:39 Quote from: TRon on October 22, 2024, 05:31:15 pmThat is why TS provided his fpc.cfg. I forgot to mention that fpc.cfg is there in the current directory after I extracted the test.zip. But yes, I must adjust the paths to match my system. I will test more later. ---------------------------------------------------------------------- TRon · 2024-10-23 02:00 @JuhaManninen: Indeed the paths must be adjusted to match the individual user's setup (could be done in a more configurable/maintainable manner if wanted). When that is 'fixed' then make sure to use something like: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fpc -n @fpc.cfg -B test_WSLCL.pasin order to override any default (system wide) fpc.cfg file. Note that I am not sure if it is required to provide the full path to the fpc.cfg file (e.g. something that I do myself). There could be more potential issues with the fpc.cfg as provided by TS (I did not have such a detailed look at it as I used my own fpc.cfg in order to compile TS' project)