Recent

Author Topic: Lazarus - Indy10 and console application linking error  (Read 1959 times)

Kasia

  • New member
  • *
  • Posts: 8
Lazarus - Indy10 and console application linking error
« on: September 27, 2020, 06:09:22 pm »
Hi,

I have Indy10 components installed in Lazarus and they work very well in graphics programs. The problem is with the console application. I wrote a simple e-mail program. However, there is a problem with linking. Well, to put components into the code, I go to Project-> Project inspector. There I choose Add-> New Requirement. In the search engine, I enter "Indy" and find "Indylaz". I add it to the requirements. Now I can add the appropriate component modules that I would like to use. However, when building the program, I get a poor message:

Quote
project1.lpr(45,1) Error: Error while linking

I googled a bit and found a similar problem: https://forum.lazarus.freepascal.org/index.php?topic=39818.0

However, as advised when following the instructions:
Quote
sudo apt-get install libgl1-mesa-dev

I get message in terminal:
Quote
libgl1-mesa-dev is already the newest version (20.0.8-0ubuntu1 ~ 20.04.1).
libgl1-mesa-dev marked as manually installed.

The problem still exists. What am I doing wrong?

Thank you!

Handoko

  • Hero Member
  • *****
  • Posts: 3913
  • My goal: build my own game engine using Lazarus
Re: Lazarus - Indy10 and console application linking error
« Reply #1 on: September 27, 2020, 06:32:53 pm »
Hello Kaska1988,
Welcome to the forum.

Error while linking message only tells us that a require library needed for building the program is missing. But because Indy has nothing to do with OpenGL and libgl* is OpenGL-related libraries, so installing libgl1-mesa-dev won't fix the issue.

Maybe you can try to install the others commonly needed libraries (for Linux):
https://forum.lazarus.freepascal.org/index.php/topic,41524.msg288242.html#msg288242

Kasia

  • New member
  • *
  • Posts: 8
Re: Lazarus - Indy10 and console application linking error
« Reply #2 on: September 28, 2020, 05:13:06 pm »
Hello,

thank you. I've done these installs:
Every time I have a problem installing on Linux I try to keep a record of what I did.
Last time I installed Lazarus (1.8.2) on Ubuntu (16.4) with a non developer profile so I had to install several libraries:

Code: Pascal  [Select][+][-]
  1.         Detail of dependencies:
  2.               o------------------o----------------------o
  3.               |   MESSAGE        |    INSTALL           |      COMMAND
  4.               O==================O======================O======================================
  5.            o- | -lgtk-x11-2.0    |                      | (Restart if needed)
  6.               | -lgdk-x11-2.0    | libgtk2.0-dev        | sudo apt-get install libgtk2.0-dev
  7.               o------------------o----------------------o
  8.            o- | -lX11            | libx11-dev           | sudo apt-get install libx11-dev
  9.               o------------------o----------------------o
  10.            o- | -lgdk_pixbuf-2.0 |                      |
  11.            o- | -lgobject-2.0    |                      |
  12.            o- | -lglib-2.0       |                      |
  13.            o- | -lgthread-2.0    |                      |
  14.            o- | -lgmodule-2.0    | libgdk-pixbuf2.0-dev | sudo apt-get install libgdk-pixbuf2.0-dev
  15.               o------------------o----------------------o
  16.            o- | -lpango-1.0      |                      |
  17.            o- | -lcairo          |                      |
  18.            o- | -lpangocairo-1.0 | libpango1.0-dev      | sudo apt-get install libpango1.0-dev
  19.               o------------------o----------------------o
  20.            o- | -latk-1.0        | libatk1.0-dev        | sudo apt-get install libatk1.0-dev
  21.               o------------------o----------------------o
  22.               Some Package Dependencies
  23.               o------------------o----------------------o
  24.               |   MESSAGE        |    INSTALL           |      COMMAND
  25.               O==================O======================O======================================
  26.            o- | -lGL             | libgl1-mesa-dev      | sudo apt-get install libgl1-mesa-dev
  27.               o------------------o----------------------o
  28.            o- | -lcl             | libcl.so             | look here http://forum.lazarus.freepascal.org/index.php?topic=28053.15
  29.               o------------------o----------------------o
  30.  
I hope it helps
But error still appears :/

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 837
    • Lebeau Software
Re: Lazarus - Indy10 and console application linking error
« Reply #3 on: September 28, 2020, 08:42:34 pm »
However, when building the program, I get a poor message:

Quote
project1.lpr(45,1) Error: Error while linking

What is the COMPLETE error message?  Which module(s) is it actually complaining about?  Please be more specific.

Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

Kasia

  • New member
  • *
  • Posts: 8
Re: Lazarus - Indy10 and console application linking error
« Reply #4 on: September 29, 2020, 04:27:19 am »
However, when building the program, I get a poor message:

Quote
project1.lpr(45,1) Error: Error while linking

What is the COMPLETE error message?  Which module(s) is it actually complaining about?  Please be more specific.
I would love too, but it is all I get: https://ibb.co/ZcDc9s2
How can I make lazarus be more specific?

zamronypj

  • Full Member
  • ***
  • Posts: 104
    • Fano Framework, Free Pascal web application framework
Fano Framework, Free Pascal web application framework https://fanoframework.github.io
Personal Projects https://v3.juhara.com
Github https://github.com/zamronypj

howardpc

  • Hero Member
  • *****
  • Posts: 3585
Re: Lazarus - Indy10 and console application linking error
« Reply #6 on: September 29, 2020, 09:51:04 pm »
It might not help at all, but you could try adding Interfaces to your uses clause (and perhaps LCL or LCLBase as a required package if it is not already specified).

Also, if Indy is threaded (I don't use it so I don't know) on Linux you will need cthreads also in your uses clause.

BSaidus

  • Sr. Member
  • ****
  • Posts: 346
  • lazarus 1.8.4 Win8.1 / cross FreeBSD
Re: Lazarus - Indy10 and console application linking error
« Reply #7 on: October 02, 2020, 03:08:22 pm »
Hello.
Add interfaces to your uses unit and check the paths inside your fpc.cfg located in the fpc\bin\i386-win32 folder.

then proceed .
lazarus 1.8.4 Win8.1 / cross FreeBSD
dhukmucmur vernadh!

Kasia

  • New member
  • *
  • Posts: 8
Re: Lazarus - Indy10 and console application linking error
« Reply #8 on: October 04, 2020, 11:11:27 am »
Hello.
Add interfaces to your uses unit and check the paths inside your fpc.cfg located in the fpc\bin\i386-win32 folder.

then proceed .
Ok thanks! I'll check that and I will let you know👍😉

Kasia

  • New member
  • *
  • Posts: 8
Re: Lazarus - Indy10 and console application linking error
« Reply #9 on: October 05, 2020, 05:05:29 pm »
Hello, I have a problem. I don't know if I'm doing it right, but I have now code like this:
Code: Pascal  [Select][+][-]
  1. program project1;
  2.  
  3. {$mode objfpc}{$H+}
  4. interface
  5. uses
  6.    {$IFDEF UNIX}{$IFDEF UseCThreads}
  7.    cthreads,
  8.    {$ENDIF}{$ENDIF}
  9.    Classes, SysUtils, indylaz, CustApp
  10.    { you can add units after this };
  11.  
  12. type
  13.  
  14.    { TMyApplication }
  15.  
  16.    TMyApplication = class(TCustomApplication)
  17.    protected
  18.       procedure DoRun; override;
  19.    public
  20.    end;
  21.  
  22. { TMyApplication }
  23.  
  24. procedure TMyApplication.DoRun;
  25. var
  26.    ErrorMsg: String;
  27. begin
  28.  
  29.    { add your program here }
  30.  
  31.    // stop program loop
  32.    Terminate;
  33. end;
  34.  
  35. var
  36.    Application: TMyApplication;
  37.  
  38. {$R *.res}
  39.  
  40. begin
  41.    Application:=TMyApplication.Create(nil);
  42.    Application.Title:='My Application';
  43.    Application.Run;
  44.    Application.Free;
  45. end.
But I get error
Quote
project1.lpr(4,10) Fatal: Syntax error, "BEGIN" expected but "INTERFACE" found
How do I fix this? And I'm using Linux, not Windows, so I can't go to path pc\bin\i386-win32.

howardpc

  • Hero Member
  • *****
  • Posts: 3585
Re: Lazarus - Indy10 and console application linking error
« Reply #10 on: October 05, 2020, 05:15:36 pm »
What you need is this
Code: Pascal  [Select][+][-]
  1. program project1
  2. {$mode objfpc}{$H+}
  3.  
  4. uses
  5. {$IFDEF UNIX}{$IFDEF UseCThreads}
  6.  cthreads,
  7. {$ENDIF}{$ENDIF}
  8. Classes, SysUtils, indylaz, CustApp, Interfaces;
  9.  
  10.  
  11. type
  12.  
  13. // etc.

BSaidus

  • Sr. Member
  • ****
  • Posts: 346
  • lazarus 1.8.4 Win8.1 / cross FreeBSD
Re: Lazarus - Indy10 and console application linking error
« Reply #11 on: October 05, 2020, 05:16:52 pm »
Hello, I have a problem. I don't know if I'm doing it right, but I have now code like this:

But I get error
Quote
project1.lpr(4,10) Fatal: Syntax error, "BEGIN" expected but "INTERFACE" found
How do I fix this? And I'm using Linux, not Windows, so I can't go to path pc\bin\i386-win32.



try this :

Code: Pascal  [Select][+][-]
  1. program project1;
  2.  
  3. {$mode objfpc}{$H+}
  4. interface
  5. uses
  6.    {$IFDEF UNIX}{$IFDEF UseCThreads}
  7.    cthreads,
  8.    {$ENDIF}{$ENDIF}
  9.    Classes, SysUtils,
  10.    interfaces,                             // add this unit into your uses
  11.    indylaz, CustApp
  12.    { you can add units after this };
  13.  
  14. type
  15.  
  16.    { TMyApplication }
  17.  
  18.    TMyApplication = class(TCustomApplication)
  19.    protected
  20.       procedure DoRun; override;
  21.    public
  22.    end;
  23.  
  24. { TMyApplication }
  25.  
  26. procedure TMyApplication.DoRun;
  27. var
  28.    ErrorMsg: String;
  29. begin
  30.    { add your program here }
  31.    // stop program loop
  32.    Terminate;
  33. end;
  34.  
  35. var
  36.    Application: TMyApplication;
  37.  
  38. {$R *.res}
  39.  
  40. begin
  41.    Application:=TMyApplication.Create(nil);
  42.    Application.Title:='My Application';
  43.    Application.Run;
  44.    Application.Free;
  45. end.
  46.  

lazarus 1.8.4 Win8.1 / cross FreeBSD
dhukmucmur vernadh!

howardpc

  • Hero Member
  • *****
  • Posts: 3585
Re: Lazarus - Indy10 and console application linking error
« Reply #12 on: October 05, 2020, 06:21:01 pm »
@BSaidus
Programs do not have an interface section, this is only for units.

Kasia

  • New member
  • *
  • Posts: 8
Re: Lazarus - Indy10 and console application linking error
« Reply #13 on: October 06, 2020, 04:25:05 pm »
Great, thanks! This error has gone. But appear another one. When I add Indy to project, IdSMTP for example, lazarus shows error that it doesn't recognize this unit. In graphic application this unit is added. What to do with that? I have code like this:
Code: Pascal  [Select][+][-]
  1. program project1;
  2.  
  3. {$mode objfpc}{$H+}
  4. uses
  5.    {$IFDEF UNIX}{$IFDEF UseCThreads}
  6.    cthreads,
  7.    {$ENDIF}{$ENDIF}
  8.    Classes, SysUtils,
  9.    interfaces,                             // add this unit into your uses
  10.    indylaz, CustApp, idSMTP
  11.    { you can add units after this };
  12.  
  13. type
  14.  
  15.    { TMyApplication }
  16.  
  17.    TMyApplication = class(TCustomApplication)
  18.    protected
  19.       procedure DoRun; override;
  20.    public
  21.    end;
  22.  
  23. { TMyApplication }
  24.  
  25. procedure TMyApplication.DoRun;
  26. var
  27.    ErrorMsg: String;
  28.    idmessage:          TIdMessage;
  29.    SMTP:               TIdSMTP;
  30. begin
  31.    { add your program here }
  32.    // stop program loop
  33.  
  34.   idMessage := TIdMessage.Create;
  35.   SMTP := TIdSMTP.Create;
  36.  
  37.   idMessage.Free;
  38.   SMTP.Free;
  39. end;
  40.  
  41. var
  42.    Application: TMyApplication;
  43.  
  44. {$R *.res}
  45.  
  46. begin
  47.    Application:=TMyApplication.Create(nil);
  48.    Application.Title:='My Application';
  49.    Application.Run;
  50.    Application.Free;
  51. end.

PascalDragon

  • Hero Member
  • *****
  • Posts: 2429
  • Compiler Developer
Re: Lazarus - Indy10 and console application linking error
« Reply #14 on: October 07, 2020, 09:22:14 am »
Great, thanks! This error has gone. But appear another one. When I add Indy to project, IdSMTP for example, lazarus shows error that it doesn't recognize this unit. In graphic application this unit is added. What to do with that? I have code like this:

You need to add the Indy package as a dependency in the Project Inspector.

 

TinyPortal © 2005-2018