Recent

Author Topic: [SOLVED] link error on Ubuntu 22.04 LTS (GNU/Linux 5.10.140 aarch64)  (Read 1084 times)

senglit

  • Full Member
  • ***
  • Posts: 135
Hi,

I have a project which can be built successfully on X86-64/Windows and arm-linux-32bit(Cortex-A9/armhf). Now I have my hardware/software changed to Cortex-A35/aarch64, software version:Ubuntu 22.04 LTS (GNU/Linux 5.10.140 aarch64).

First I installed gcc lib by
Code: Text  [Select][+][-]
  1. apt install build-essential
  2.  

Then, I downloaded fpc-3.2.2.aarch64-linux.tar and installed FPC by command ./install.sh. Then I began to build my project by:
Code: Pascal  [Select][+][-]
  1. fpc devices485.lpr -Fulnet\* -Fusysnapse40.1\*          #it works on Cortex-A9/armhf
  2.  

But then I got these messages and I got no idea how to solve it. Any body can help? thanks!
Code: Text  [Select][+][-]
  1. Free Pascal Compiler version 3.2.2 [2021/05/23] for aarch64
  2. Copyright (c) 1993-2021 by Florian Klaempfl and others
  3. Target OS: Linux for AArch64
  4. Compiling devices485.lpr
  5. Compiling modbus.pas
  6. Compiling ./synapse40.1/synaser.pas
  7. Compiling ./synapse40.1/synafpc.pas
  8. Assembling synafpc
  9. Compiling ./synapse40.1/synautil.pas
  10. synautil.pas(645,96) Warning: Symbol "TimeSeparator" is deprecated
  11. synautil.pas(1989,3) Note: Local variable "BackStop" is assigned but never used
  12. synautil.pas(2129,88) Warning: Symbol "ShortMonthNames" is deprecated
  13. synautil.pas(2130,87) Warning: Symbol "ShortMonthNames" is deprecated
  14. Assembling synautil
  15. synaser.pas(1017,58) Note: Call to subroutine "function FpOpen(const path:RawByteString;flags:LongInt):LongInt;" marked as inline is not inlined
  16. synaser.pas(2428,34) Warning: range check error while evaluating constants (4294967295 must be between -2147483648 and 2147483647)
  17. synaser.pas(2438,36) Warning: range check error while evaluating constants (4294967295 must be between -2147483648 and 2147483647)
  18. synaser.pas(2447,35) Warning: range check error while evaluating constants (4294967295 must be between -2147483648 and 2147483647)
  19. Assembling synaser
  20. Compiling ./lnet/lnet.pp
  21. Compiling ./lnet/levents.pp
  22. Compiling ./lnet/lcommon.pp
  23. lcommon.pp(388,28) Note: Call to subroutine "function StrToHostAddr(const IP:AnsiString):DWord;" marked as inline is not inlined
  24. lcommon.pp(390,37) Note: Call to subroutine "function StrToHostAddr(const IP:AnsiString):DWord;" marked as inline is not inlined
  25. lcommon.pp(400,15) Note: Call to subroutine "function HostAddrToStr(const Entry:LongWord):AnsiString;" marked as inline is not inlined
  26. lcommon.pp(402,15) Note: Call to subroutine "function NetAddrToStr(const Entry:LongWord):AnsiString;" marked as inline is not inlined
  27. Assembling lcommon
  28. Assembling levents
  29. lnet.pp(778,30) Warning: User defined: check if we need aOp = soSend in the IF, perhaps bad recv is possible?
  30. lnet.pp(1628,3) Note: Call to subroutine "procedure TLSession.CallReceiveEvent(aHandle:TLHandle);" marked as inline is not inlined
  31. lnet.pp(1634,3) Note: Call to subroutine "procedure TLSession.CallSendEvent(aHandle:TLHandle);" marked as inline is not inlined
  32. lnet.pp(1640,3) Note: Call to subroutine "procedure TLSession.CallErrorEvent(aHandle:TLHandle;const msg:AnsiString);" marked as inline is not inlined
  33. lnet.pp(1646,3) Note: Call to subroutine "procedure TLSession.CallConnectEvent(aHandle:TLHandle);" marked as inline is not inlined
  34. lnet.pp(1652,3) Note: Call to subroutine "procedure TLSession.CallAcceptEvent(aHandle:TLHandle);" marked as inline is not inlined
  35. lnet.pp(1658,3) Note: Call to subroutine "procedure TLSession.CallDisconnectEvent(aHandle:TLHandle);" marked as inline is not inlined
  36. Assembling lnet
  37. Compiling exchangedata.pas
  38. Assembling exchangedata
  39. modbus.pas(577,3) Note: Local variable "TransactionID" is assigned but never used
  40. Assembling modbus
  41. Compiling www.pas
  42. Assembling www
  43. Compiling ./lnet/lnetbase.pas
  44. Compiling ./lnet/lftp.pp
  45. Compiling ./lnet/ltelnet.pp
  46. Compiling ./lnet/lcontrolstack.pp
  47. Compiling ./lnet/ltelnet.pp
  48. Assembling ltelnet
  49. Assembling lcontrolstack
  50. Assembling lftp
  51. Compiling ./lnet/lsmtp.pp
  52. Compiling ./lnet/lmimewrapper.pp
  53. Compiling ./lnet/lmimestreams.pp
  54. Assembling lmimestreams
  55. Assembling lmimewrapper
  56. Assembling lsmtp
  57. Compiling ./lnet/lhttp.pp
  58. Compiling ./lnet/lnetssl.pp
  59. lnetssl.pp(202,24) Warning: Symbol "GetConnected" is deprecated
  60. Assembling lnetssl
  61. Compiling ./lnet/lhttputil.pp
  62. lhttputil.pp(149,26) Note: Call to subroutine "function TZSeconds:LongInt;" marked as inline is not inlined
  63. lhttputil.pp(154,26) Note: Call to subroutine "function TZSeconds:LongInt;" marked as inline is not inlined
  64. Assembling lhttputil
  65. Compiling ./lnet/lstrbuffer.pp
  66. Assembling lstrbuffer
  67. lhttp.pp(1307,9) Note: Call to subroutine "function CompareMem(P1:Pointer;P2:Pointer;Length:QWord):Boolean;" marked as inline is not inlined
  68. lhttp.pp(1647,11) Note: Call to subroutine "function CompareMem(P1:Pointer;P2:Pointer;Length:QWord):Boolean;" marked as inline is not inlined
  69. lhttp.pp(1943,6) Note: Call to subroutine "function TZSeconds:LongInt;" marked as inline is not inlined
  70. lhttp.pp(1947,29) Note: Call to subroutine "function TZSeconds:LongInt;" marked as inline is not inlined
  71. Assembling lhttp
  72. Compiling ./lnet/lwebserver.pp
  73. Compiling ./lnet/lmimetypes.pp
  74. Assembling lmimetypes
  75. Compiling ./lnet/lprocess.pp
  76. Assembling lprocess
  77. Compiling ./lnet/lfastcgi.pp
  78. Compiling ./lnet/fastcgi_base.pp
  79. Assembling fastcgi_base
  80. Compiling ./lnet/ltimer.pp
  81. Assembling ltimer
  82. Compiling ./lnet/lspawnfcgi.pp
  83. Assembling lspawnfcgi
  84. Assembling lfastcgi
  85. lwebserver.pp(1124,4) Warning: User defined: TODO
  86. Assembling lwebserver
  87. Compiling ./lnet/lthreadevents.pp
  88. Assembling lthreadevents
  89. Assembling devices485
  90. Linking devices485
  91. /usr/bin/ld: /usr/lib/fpc/3.2.2/units/aarch64-linux/rtl/cprt0.o: in function `_start':
  92. (.text+0x54): undefined reference to `__libc_csu_init'
  93. /usr/bin/ld: (.text+0x58): undefined reference to `__libc_csu_init'
  94. /usr/bin/ld: (.text+0x5c): undefined reference to `__libc_csu_fini'
  95. /usr/bin/ld: (.text+0x60): undefined reference to `__libc_csu_fini'
  96. devices485.lpr(140) Error: Error while linking
  97. devices485.lpr(140) Fatal: There were 1 errors compiling module, stopping
  98. Fatal: Compilation aborted
  99. Error: /usr/bin/ppca64 returned an error exitcode
  100.  
« Last Edit: April 03, 2025, 03:02:19 pm by senglit »
I use Win11 + Lazarus3.6 + FPC Trunk. fpcupdeluxe

TRon

  • Hero Member
  • *****
  • Posts: 4296
Re: link error on Ubuntu 22.04 LTS (GNU/Linux 5.10.140 aarch64)
« Reply #1 on: March 25, 2025, 06:32:10 pm »
Fixed in trunk see #39295
Today is tomorrow's yesterday.

senglit

  • Full Member
  • ***
  • Posts: 135
Re: link error on Ubuntu 22.04 LTS (GNU/Linux 5.10.140 aarch64)
« Reply #2 on: March 26, 2025, 03:21:50 am »
Thank you. I took a look at issue #39295 and tried to install FPC from source file. But I'm really not familiar with fpc make and failed several times.

Is there any package which already solved this issue and can be installed by simply ./install.sh ?

Fixed in trunk see #39295
I use Win11 + Lazarus3.6 + FPC Trunk. fpcupdeluxe

TRon

  • Hero Member
  • *****
  • Posts: 4296
Re: link error on Ubuntu 22.04 LTS (GNU/Linux 5.10.140 aarch64)
« Reply #3 on: March 26, 2025, 04:18:40 am »
Yeah, sorry. I noticed trunk did not build starting this week or so.

You could try here.

Select the directory that matches desired platform and see if there the build listed is newer than the date of the commit mentioned in the issue-report (should be no problem).

PS: don't mix your installations though. Make sure to backup your existing FPC 3.2.2 configuration in case installed when used a package-manager and/or .deb file.
« Last Edit: March 26, 2025, 04:22:36 am by TRon »
Today is tomorrow's yesterday.

Thaddy

  • Hero Member
  • *****
  • Posts: 16783
  • Ceterum censeo Trump esse delendam
Re: link error on Ubuntu 22.04 LTS (GNU/Linux 5.10.140 aarch64)
« Reply #4 on: March 26, 2025, 07:06:39 am »
Back to the original question, here are scripts based on mine, with small differences.
For Ubuntu or Debian or Raspberry OS, clean new install:
Code: Bash  [Select][+][-]
  1. #!/bin/bash
  2. #
  3. # script for installing a completely fresh trunk version of freepascal
  4. # does not use fpcupdeluxe and install according to OS rules
  5. # you run this only once! after this you should run the updfpc.sh script
  6. #
  7.  
  8. # Get the user’s home directory (works with sudo)
  9. if [ -n "$SUDO_USER" ]; then
  10.     user_home=$(getent passwd "$SUDO_USER" | cut -d: -f6)
  11. else
  12.     user_home="$HOME"
  13. fi
  14. cd "$user_home"
  15. apt install git
  16. git clone https://gitlab.com/freepascal.org/fpc/source.git fpc
  17. apt install build-essential
  18. # not a full install, just the basic compiler and tools
  19. apt install fp-compiler
  20. # Then build the full compiler:
  21. cd "$user_home/fpc"
  22. make clean all install PP=/usr/bin/ppca64-3.2.2 PREFIX=/usr
  23. # Copy over the newly build compiler (or create a symlink).
  24. cp /usr/lib/fpc/3.3.1/ppca64 /usr/bin
  25. exit 0
You can save this shellscript as e.g. newfpc.sh and make it executable. You should run it with sudo rights

To update an existing install:
Code: Bash  [Select][+][-]
  1. #!/bin/bash
  2. #
  3. # script to update an existing install
  4. #
  5.  
  6. # go to fpc directory
  7. # Get user’s home directory (works with sudo)
  8. user_home=$(getent passwd "${SUDO_USER:-$USER}" | cut -d: -f6)
  9.  
  10. # Attempt to cd into ~/fpc
  11. if cd "$user_home/fpc"; then
  12.     echo "Success! Now in: $(pwd)"
  13. else
  14.     echo "Error: $user_home/fpc does not exist." >&2
  15.     exit 1
  16. fi
  17. cd "user_home/fpc"
  18. # update sources
  19. git pull
  20. # make the new compiler
  21. make clean all install PP=/usr/bin/ppca64-3.2.2 PREFIX=/usr
  22. # Copy over the newly build compiler (or create a symlink).
  23. cp /usr/lib/fpc/3.3.1/ppca64 /usr/bin
  24. exit 0
Save as e.g. updfpc.sh , make executable and run with sudo rights

« Last Edit: March 26, 2025, 10:06:24 am by Thaddy »
Changing servers. thaddy.com may be temporary unreachable but restored when the domain name transfer is done.

Thaddy

  • Hero Member
  • *****
  • Posts: 16783
  • Ceterum censeo Trump esse delendam
Re: link error on Ubuntu 22.04 LTS (GNU/Linux 5.10.140 aarch64)
« Reply #5 on: March 26, 2025, 09:02:12 am »
I just noticed a small error in the update script:
It works, but only once. You can run it once but a second time fails because then the renamed compiler ppcx64-322 becomes actually the trunk compiler
I will fix that.
FIXED
Cause: I overlooked that installing the fp-compiler package already creates a symlink /usr/bin/ppcx64-3.2.2, so it is not necessary to rename the compiler.

Parts of the scripts are snippet based, so there maybe room for improvement, but this works.
« Last Edit: March 26, 2025, 09:40:11 am by Thaddy »
Changing servers. thaddy.com may be temporary unreachable but restored when the domain name transfer is done.

tetrastes

  • Hero Member
  • *****
  • Posts: 640
Re: link error on Ubuntu 22.04 LTS (GNU/Linux 5.10.140 aarch64)
« Reply #6 on: March 26, 2025, 02:06:17 pm »
Thank you. I took a look at issue #39295 and tried to install FPC from source file. But I'm really not familiar with fpc make and failed several times.

Is there any package which already solved this issue and can be installed by simply ./install.sh ?

There is Fpcupdeluxe for aarch64-linux https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/tag/v2.4.0f.

senglit

  • Full Member
  • ***
  • Posts: 135
Re: link error on Ubuntu 22.04 LTS (GNU/Linux 5.10.140 aarch64)
« Reply #7 on: April 02, 2025, 04:52:07 pm »
Still struggling.

root@htnice:~# ./fpcupdeluxe-aarch64-linux
./fpcupdeluxe-aarch64-linux: error while loading shared libraries: libgdk-x11-2.0.so.0: cannot open shared object file: No such file or directory

root@htnice:~# apt install fp-compiler
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package fp-compiler

tar file from https://downloads.freepascal.org/fpc/snapshot/trunk/aarch64-linux/ : unpacked with 3 folders: bin, share, lib. I don't know how to install it.

 :'(

I use Win11 + Lazarus3.6 + FPC Trunk. fpcupdeluxe

TRon

  • Hero Member
  • *****
  • Posts: 4296
Re: link error on Ubuntu 22.04 LTS (GNU/Linux 5.10.140 aarch64)
« Reply #8 on: April 02, 2025, 05:44:41 pm »
OMG. just pick /one/ method and stick to it. Going the yolo route only provides more issues down the road.
 
Quote
./fpcupdeluxe-aarch64-linux: error while loading shared libraries: libgdk-x11-2.0.so.0: cannot open shared object file: No such file or directory
prerequisites for FPCUpDeluxe on linux

Quote
E: Unable to locate package fp-compiler
What distribution are you using that it does not contain package fp-compiler ?

btw not required for FPCUpDeluxe, only if you install the FPC compiler manually (and on top of that install Lazarus manually).

Quote
tar file from https://downloads.freepascal.org/fpc/snapshot/trunk/aarch64-linux/ : unpacked with 3 folders: bin, share, lib. I don't know how to install it.
Yeah I noticed the installation script is missing from that tarball. No idea why. Also not required for FPCUpDeluxe.

First, pick a method (and stick to it). There is no use cooking up a script if you're going FPCUpdeluxe route anyway as it does everything for you (except install the dependencies. Might require to install the dev packages for these dependencies as well when using a debian based distribution).
Today is tomorrow's yesterday.

senglit

  • Full Member
  • ***
  • Posts: 135
Re: link error on Ubuntu 22.04 LTS (GNU/Linux 5.10.140 aarch64)
« Reply #9 on: April 03, 2025, 03:01:59 pm »
Thanks!
I stick to fpcupdeluxe and ... I still failed on building FPC enviroment on aarch64-linux, but I built a cross compile enviroment on win11 which can build executable file for any cpu and os. Giving I write my source code on win11, it's even better than buiding env on aarch64-linux.

OMG. just pick /one/ method and stick to it. Going the yolo route only provides more issues down the road.
 
I use Win11 + Lazarus3.6 + FPC Trunk. fpcupdeluxe

TRon

  • Hero Member
  • *****
  • Posts: 4296
Re: link error on Ubuntu 22.04 LTS (GNU/Linux 5.10.140 aarch64)
« Reply #10 on: April 03, 2025, 03:49:13 pm »
I stick to fpcupdeluxe and ... I still failed on building FPC enviroment on aarch64-linux,
Failed is a non-computable terminology :) (fwiw: it works for me but at the same time some trunk combinations of FPC/Lazarus might fail to build...)

Quote
but I built a cross compile enviroment on win11 which can build executable file for any cpu and os. Giving I write my source code on win11, it's even better than buiding env on aarch64-linux.
Good that you got it solved. Thank you for reporting back.
Today is tomorrow's yesterday.

 

TinyPortal © 2005-2018