[Lazarus] Cannot compile console application, why?

Bo Berglund bo.berglund at gmail.com
Tue Jul 21 21:14:39 CEST 2020


On Mon, 06 Jul 2020 00:49:26 +0200, Bo Berglund via lazarus
<lazarus at lists.lazarus-ide.org> wrote:

>I have created a test application using Lazarus 2.0.8 and fpc 3.0.4 on
>Windows 10.
>
>The purpose is to check some Indy10 TCP communications items before
>putting them into the main project.
>
>So I have created a new project as a console application and
>implemented my test Indy code.
>
>When I use "Run/Quick compile" it reports no errors so then I tried to
>use "Run/Compile" in order to get an executable but now it shows a
>large number of errors of this kind:
>
>IndyTest.lpr(76,1) Error: Undefined symbol: WSRegisterMenuItem
>
>I have even gone into the project options/compiler options/additions
>and overrides and set the widgetset to nongui (as I have been taught
>before).
>But nothing seems to help.
>Same if I create the project as a "Program"...
>
>I have added indylaz as required package and also later LCLbase, but
>the errors persist.
>Building the program leaves me at the last source line:
>
>end.
>
>with all these apparently GUI-related errors.
>
>What have I done wrong here?
>

FOLLOW-UP on the problem (for future reference)
-----------------------------------------------
After solving this problem as described earlier in this thread I went
on with my Delphi->FreePascal porting of an old project, which also
needed a serial port replacement component.
I chose LazSerial (available via Online Package Manager in Lazarus).

Now the same problem as outlined earlier in this thread popped up
again! In this case I found a few threads in the Lazarus forum where
the problem had a solution:
https://forum.lazarus.freepascal.org/index.php/topic,7143.msg33501.html
https://forum.lazarus.freepascal.org/index.php/topic,21998.msg129236.html

In the unit where LazSerial is referenced I added an extra uses item
like this:

  {$IFDEF FPC}
    interfaces, //Needed for LazSerial to work in a Console program
    LazSerial,  //The serial component
  {$ELSE} //Delphi

When I now build the project the linker does not trigger any
complaints about missing Menu related identifiers and the build
succeeds!
 

-- 
Bo Berglund
Developer in Sweden



More information about the lazarus mailing list