[SOLVED] link error on Ubuntu 22.04 LTS (GNU/Linux 5.10.140 aarch64) lazarus / 62-General ---------------------------------------------------------------------- senglit · 2025-03-25 17:20 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i apt install build-essential  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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fpc devices485.lpr -Fulnet\* -Fusysnapse40.1\*          #it works on Cortex-A9/armhf  But then I got these messages and I got no idea how to solve it. Any body can help? thanks! Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Free Pascal Compiler version 3.2.2 [2021/05/23] for aarch64Copyright (c) 1993-2021 by Florian Klaempfl and othersTarget OS: Linux for AArch64Compiling devices485.lprCompiling modbus.pasCompiling ./synapse40.1/synaser.pasCompiling ./synapse40.1/synafpc.pasAssembling synafpcCompiling ./synapse40.1/synautil.passynautil.pas(645,96) Warning: Symbol "TimeSeparator" is deprecatedsynautil.pas(1989,3) Note: Local variable "BackStop" is assigned but never usedsynautil.pas(2129,88) Warning: Symbol "ShortMonthNames" is deprecatedsynautil.pas(2130,87) Warning: Symbol "ShortMonthNames" is deprecatedAssembling synautilsynaser.pas(1017,58) Note: Call to subroutine "function FpOpen(const path:RawByteString;flags:LongInt):LongInt;" marked as inline is not inlinedsynaser.pas(2428,34) Warning: range check error while evaluating constants (4294967295 must be between -2147483648 and 2147483647)synaser.pas(2438,36) Warning: range check error while evaluating constants (4294967295 must be between -2147483648 and 2147483647)synaser.pas(2447,35) Warning: range check error while evaluating constants (4294967295 must be between -2147483648 and 2147483647)Assembling synaserCompiling ./lnet/lnet.ppCompiling ./lnet/levents.ppCompiling ./lnet/lcommon.pplcommon.pp(388,28) Note: Call to subroutine "function StrToHostAddr(const IP:AnsiString):DWord;" marked as inline is not inlinedlcommon.pp(390,37) Note: Call to subroutine "function StrToHostAddr(const IP:AnsiString):DWord;" marked as inline is not inlinedlcommon.pp(400,15) Note: Call to subroutine "function HostAddrToStr(const Entry:LongWord):AnsiString;" marked as inline is not inlinedlcommon.pp(402,15) Note: Call to subroutine "function NetAddrToStr(const Entry:LongWord):AnsiString;" marked as inline is not inlinedAssembling lcommonAssembling leventslnet.pp(778,30) Warning: User defined: check if we need aOp = soSend in the IF, perhaps bad recv is possible?lnet.pp(1628,3) Note: Call to subroutine "procedure TLSession.CallReceiveEvent(aHandle:TLHandle);" marked as inline is not inlinedlnet.pp(1634,3) Note: Call to subroutine "procedure TLSession.CallSendEvent(aHandle:TLHandle);" marked as inline is not inlinedlnet.pp(1640,3) Note: Call to subroutine "procedure TLSession.CallErrorEvent(aHandle:TLHandle;const msg:AnsiString);" marked as inline is not inlinedlnet.pp(1646,3) Note: Call to subroutine "procedure TLSession.CallConnectEvent(aHandle:TLHandle);" marked as inline is not inlinedlnet.pp(1652,3) Note: Call to subroutine "procedure TLSession.CallAcceptEvent(aHandle:TLHandle);" marked as inline is not inlinedlnet.pp(1658,3) Note: Call to subroutine "procedure TLSession.CallDisconnectEvent(aHandle:TLHandle);" marked as inline is not inlinedAssembling lnetCompiling exchangedata.pasAssembling exchangedatamodbus.pas(577,3) Note: Local variable "TransactionID" is assigned but never usedAssembling modbusCompiling www.pasAssembling wwwCompiling ./lnet/lnetbase.pasCompiling ./lnet/lftp.ppCompiling ./lnet/ltelnet.ppCompiling ./lnet/lcontrolstack.ppCompiling ./lnet/ltelnet.ppAssembling ltelnetAssembling lcontrolstackAssembling lftpCompiling ./lnet/lsmtp.ppCompiling ./lnet/lmimewrapper.ppCompiling ./lnet/lmimestreams.ppAssembling lmimestreamsAssembling lmimewrapperAssembling lsmtpCompiling ./lnet/lhttp.ppCompiling ./lnet/lnetssl.pplnetssl.pp(202,24) Warning: Symbol "GetConnected" is deprecatedAssembling lnetsslCompiling ./lnet/lhttputil.pplhttputil.pp(149,26) Note: Call to subroutine "function TZSeconds:LongInt;" marked as inline is not inlinedlhttputil.pp(154,26) Note: Call to subroutine "function TZSeconds:LongInt;" marked as inline is not inlinedAssembling lhttputilCompiling ./lnet/lstrbuffer.ppAssembling lstrbufferlhttp.pp(1307,9) Note: Call to subroutine "function CompareMem(P1:Pointer;P2:Pointer;Length:QWord):Boolean;" marked as inline is not inlinedlhttp.pp(1647,11) Note: Call to subroutine "function CompareMem(P1:Pointer;P2:Pointer;Length:QWord):Boolean;" marked as inline is not inlinedlhttp.pp(1943,6) Note: Call to subroutine "function TZSeconds:LongInt;" marked as inline is not inlinedlhttp.pp(1947,29) Note: Call to subroutine "function TZSeconds:LongInt;" marked as inline is not inlinedAssembling lhttpCompiling ./lnet/lwebserver.ppCompiling ./lnet/lmimetypes.ppAssembling lmimetypesCompiling ./lnet/lprocess.ppAssembling lprocessCompiling ./lnet/lfastcgi.ppCompiling ./lnet/fastcgi_base.ppAssembling fastcgi_baseCompiling ./lnet/ltimer.ppAssembling ltimerCompiling ./lnet/lspawnfcgi.ppAssembling lspawnfcgiAssembling lfastcgilwebserver.pp(1124,4) Warning: User defined: TODOAssembling lwebserverCompiling ./lnet/lthreadevents.ppAssembling lthreadeventsAssembling devices485Linking devices485/usr/bin/ld: /usr/lib/fpc/3.2.2/units/aarch64-linux/rtl/cprt0.o: in function `_start':(.text+0x54): undefined reference to `__libc_csu_init'/usr/bin/ld: (.text+0x58): undefined reference to `__libc_csu_init'/usr/bin/ld: (.text+0x5c): undefined reference to `__libc_csu_fini'/usr/bin/ld: (.text+0x60): undefined reference to `__libc_csu_fini'devices485.lpr(140) Error: Error while linkingdevices485.lpr(140) Fatal: There were 1 errors compiling module, stoppingFatal: Compilation abortedError: /usr/bin/ppca64 returned an error exitcode ---------------------------------------------------------------------- TRon · 2025-03-25 17:32 Fixed in trunk see #39295 ---------------------------------------------------------------------- senglit · 2025-03-26 02:21 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 ? Quote from: TRon on March 25, 2025, 06:32:10 pmFixed in trunk see #39295 ---------------------------------------------------------------------- TRon · 2025-03-26 03:18 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. ---------------------------------------------------------------------- Thaddy · 2025-03-26 06:06 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i #!/bin/bash## script for installing a completely fresh trunk version of freepascal# does not use fpcupdeluxe and install according to OS rules# you run this only once! after this you should run the updfpc.sh script# # Get the user’s home directory (works with sudo)if [ -n "$SUDO_USER" ]; then    user_home=$(getent passwd "$SUDO_USER" | cut -d: -f6)else    user_home="$HOME"ficd "$user_home"apt install gitgit clone https://gitlab.com/freepascal.org/fpc/source.git fpcapt install build-essential# not a full install, just the basic compiler and toolsapt install fp-compiler# Then build the full compiler:cd "$user_home/fpc"make clean all install PP=/usr/bin/ppca64-3.2.2 PREFIX=/usr# Copy over the newly build compiler (or create a symlink).cp /usr/lib/fpc/3.3.1/ppca64 /usr/binexit 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i #!/bin/bash## script to update an existing install# # go to fpc directory# Get user’s home directory (works with sudo)user_home=$(getent passwd "${SUDO_USER:-$USER}" | cut -d: -f6) # Attempt to cd into ~/fpcif cd "$user_home/fpc"; then    echo "Success! Now in: $(pwd)"else    echo "Error: $user_home/fpc does not exist." >&2    exit 1ficd "user_home/fpc"# update sourcesgit pull# make the new compilermake clean all install PP=/usr/bin/ppca64-3.2.2 PREFIX=/usr# Copy over the newly build compiler (or create a symlink).cp /usr/lib/fpc/3.3.1/ppca64 /usr/binexit 0Save as e.g. updfpc.sh , make executable and run with sudo rights ---------------------------------------------------------------------- Thaddy · 2025-03-26 08:02 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. ---------------------------------------------------------------------- tetrastes · 2025-03-26 13:06 Quote from: senglit on March 26, 2025, 03:21:50 amThank 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 · 2025-04-02 14:52 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.  :'( ---------------------------------------------------------------------- TRon · 2025-04-02 15:44 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 QuoteE: 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). Quotetar 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). ---------------------------------------------------------------------- senglit · 2025-04-03 13:01 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. Quote from: TRon on April 02, 2025, 05:44:41 pmOMG. just pick /one/ method and stick to it. Going the yolo route only provides more issues down the road. ---------------------------------------------------------------------- TRon · 2025-04-03 13:49 Quote from: senglit on April 03, 2025, 03:01:59 pmI 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...) Quotebut 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.