Recent

Author Topic: Needed units in non-form programs [SOLVED]  (Read 754 times)

pascal111

  • Sr. Member
  • ****
  • Posts: 359
  • Un trabajo en equipo para programas serias.
Needed units in non-form programs [SOLVED]
« on: September 02, 2021, 08:58:24 pm »
What's the needed units in this case to make dialogs work?

Code: Pascal  [Select][+][-]
  1. program Project1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  7.   cthreads,
  8.   {$ENDIF}{$ENDIF}
  9.   Classes
  10.   { you can add units after this };
  11.  
  12. begin
  13.  
  14.   showmessage('Hello World!');
  15.  
  16. end.
  17.  
  18.  
« Last Edit: September 02, 2021, 10:57:46 pm by pascal111 »

GetMem

  • Hero Member
  • *****
  • Posts: 3493
Re: Needed units in non-form programs
« Reply #1 on: September 02, 2021, 09:39:11 pm »
1. Project Inspector(Lazarus Menu/Project)->Required Packages->Add "LCL"
2. See below:
Code: Pascal  [Select][+][-]
  1. program Project1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   Interfaces, //make sure unit Interfaces is first in the list
  7.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  8.   cthreads,
  9.   {$ENDIF}{$ENDIF}
  10.   Classes, Dialogs; //add dialogs  
  11.  
  12. begin
  13.   showmessage('Hello World!');
  14. end.

pascal111

  • Sr. Member
  • ****
  • Posts: 359
  • Un trabajo en equipo para programas serias.
Re: Needed units in non-form programs
« Reply #2 on: September 02, 2021, 10:37:00 pm »
I get this error:

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 9600
  • FPC developer.
Re: Needed units in non-form programs
« Reply #3 on: September 02, 2021, 10:43:21 pm »
Seems to be linking related, and so probably missing installed libraries (or corresponding -dev(el) libraries).   Check your GTK installation, if that is what you use.

For more info, right click on the messages, and change the filtering properties to none and recompile to check what exact library is missing

pascal111

  • Sr. Member
  • ****
  • Posts: 359
  • Un trabajo en equipo para programas serias.
Re: Needed units in non-form programs
« Reply #4 on: September 02, 2021, 10:54:37 pm »
Unfortunately, when I copied @GetMem modified code, I found that I forgot to type "Interfaces" under "uses" section, it works now.

 

TinyPortal © 2005-2018