#1 2016-11-02 15:10:13

tklaz
Member
Registered: 2016-11-02
Posts: 10

Linker error: Error while linking

Hi,
this is the same question as: http://forum.lazarus.freepascal.org/ind … 651.0.html
This time at correct place:

I could not find any usable info to resolve this error:

Compile Project, OS: linux, Target: C:\Users\tk\AppData\Local\Temp\project1: Exit code 1, Errors: 1
project1.lpr(20,1) Error: Error while linking

I use NewPascal distribution on Win7/x64 and try to crosscompile for linux i386 for the first time (package CrossLinuxi386.rar). Compilation runs fine but I get this error for every project (even for the fresh empty app).

Everywhere else I could only find error messages stating that some library is missing for the linker, but no such report in my case, just "Error while linking".

Thank you

tk

EDIT: Just checked if using correct linker: c:\newpascal\cross\bin\i386-linux\i386-linux-ld.exe produces the error, when I remove it Lazarus misses this file.

Last edited by tklaz (2016-11-02 15:23:02)

Offline

#2 2016-11-02 15:28:34

AOG
Member
Registered: 2014-02-24
Posts: 349

Re: Linker error: Error while linking

Answer here : http://synopse.info/forum/viewtopic.php … 363#p20363

And here : http://bugs.freepascal.org/view.php?id=30112

Answer:

{$ifdef Linux}
  {$ifdef FPC_CROSSCOMPILING}
    {$ifdef CPUARM}
      //if GUI, then uncomment
      //{$linklib GLESv2}
    {$endif}
    {$linklib libc_nonshared.a}
  {$endif}
{$endif}

Add this into the top of your lpr file !

Last edited by AOG (2016-11-02 15:29:08)

Offline

#3 2016-11-02 15:39:23

tklaz
Member
Registered: 2016-11-02
Posts: 10

Re: Linker error: Error while linking

Thank you, works for an exe but does not for a library.

library Project1;

{$ifdef Linux}
  {$ifdef FPC_CROSSCOMPILING}
    {$ifdef CPUARM}
      //if GUI, then uncomment
      //{$linklib GLESv2}
    {$endif}
    {$linklib libc_nonshared.a}
  {$endif}
{$endif}

{$mode objfpc}{$H+}

uses
  Classes
  { you can add units after this };

begin
end. 

Where can I find extended info what causes the error? Thanks

Offline

#4 2016-11-02 16:18:29

AOG
Member
Registered: 2014-02-24
Posts: 349

Re: Linker error: Error while linking

Add this to the Custom Options of the Compiler Options (in Project Options):

-FLC:\NewPascal\cross\lib\i386-linux\ld-linux.so.2

Last edited by AOG (2016-11-02 16:19:25)

Offline

#5 2016-11-02 16:57:35

tklaz
Member
Registered: 2016-11-02
Posts: 10

Re: Linker error: Error while linking

Was almost there, only not used the full path for the -FL directive!

Finally got this error for a fresh library:

C:\NewPascal\cross\bin\i386-linux\i386-linux-ld.exe: cannot find /lib/ld-linux.so.2

Searched a bit in FPC doc and found the directive -FL.



Works fine now, tested the exe and all *.so on my Ubuntu now.

Thank you!

Offline

Board footer

Powered by FluxBB