Re: [Lazarus] Cannot compile console application, why?
On Mon, 06 Jul 2020 00:49:26 +0200, Bo Berglund via lazarus 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 -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] Cannot compile console application, why?
On 06/07/2020 6:20 am, Michael Van Canneyt via lazarus wrote: > I suggest to remove indylaz from the uses clause. > It pulls in some GUI related code, probably some design-time stuff. Yeah, from memory, the non-gui related package is called "indy.lpk" Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] Cannot compile console application, why?
On Mon, 6 Jul 2020 12:25:25 +0200 (CEST), Michael Van Canneyt via lazarus wrote: >StdCtrls :-) > >That's what I said, you have GUI dependencies in your code... > The Indy test unit implements a simple TCP server and is based on an example I managed to find on the net. That example used a form to display data rather than using the command line But I also had to remove that Indy unit before the errors went away. I have now tested that I can run the server on Win10 and connect to it. So I can now move forward. Thanks! -- Bo Berglund Developer in Sweden -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] Cannot compile console application, why?
On Mon, 6 Jul 2020, Bo Berglund via lazarus wrote: On Mon, 6 Jul 2020 07:20:08 +0200 (CEST), Michael Van Canneyt via lazarus wrote: I suggest to remove indylaz from the uses clause. It pulls in some GUI related code, probably some design-time stuff. So I have done this: - deleted the uses indylaz in the lpr file - removed the LCLbase from project required packages Still the same behaviour. LCLbase was not there to begin with, I added it as a wild guess but it did nothing so is now removed. Next I started removing uses clauses one by one in the remoteserver.pas unit where the indy functionality is located and when I had removed these two it did build! //StdCtrls, //IdBaseComponent, StdCtrls :-) That's what I said, you have GUI dependencies in your code... QUESTION: - What is the correct way to start a new project that is just a console no GUI type program intended to be run as a systemd service on Linux? There are several types of programs to choose from and I have not understood the difference between: - Simple Program - Program - Console application They are exactly the same functionally, they just differ in terms of what start code is generated. Michael. -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] Cannot compile console application, why?
On Mon, 6 Jul 2020 07:20:08 +0200 (CEST), Michael Van Canneyt via lazarus wrote: >I suggest to remove indylaz from the uses clause. >It pulls in some GUI related code, probably some design-time stuff. > So I have done this: - deleted the uses indylaz in the lpr file - removed the LCLbase from project required packages Still the same behaviour. LCLbase was not there to begin with, I added it as a wild guess but it did nothing so is now removed. Next I started removing uses clauses one by one in the remoteserver.pas unit where the indy functionality is located and when I had removed these two it did build! //StdCtrls, //IdBaseComponent, QUESTION: - What is the correct way to start a new project that is just a console no GUI type program intended to be run as a systemd service on Linux? There are several types of programs to choose from and I have not understood the difference between: - Simple Program - Program - Console application -- Bo Berglund Developer in Sweden -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] Cannot compile console application, why?
On Mon, 6 Jul 2020, Bo Berglund via lazarus 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 Looks like you have some GUI related code somewhere. program IndyTest; {$mode objfpc}{$H+} uses {$IFDEF UNIX} cthreads, {$ENDIF} Classes, SysUtils, CustApp, { you can add units after this } crt, //to check keypresses remoteserver, //where the main action happens indylaz; I suggest to remove indylaz from the uses clause. It pulls in some GUI related code, probably some design-time stuff. Michael. -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus