Error linking in crosscompile lazarus / 1-Linux ---------------------------------------------------------------------- BlueIcaro · 2020-10-28 10:48 Hello, I have a binding unit to a library. In my unit I have this code: Code: [Select]  gevlib = 'libGevApi.so';  (...) // Get the number of Gev devices seen by the system. //Test OK. function GevDeviceCount(): integer; cdecl; external gevlib;  I programing in Ubuntu 18.04-AMD64. I use a fpcdeluxe lazarus build, because the final code will run in arm-linux. When I test the code in my laptop, I have any issue. But when I change to arm-linux compile mode I got the following error: QuoteCompilar proyecto, Modo: jetson, CPU: arm, Objetivo: bin/linux- arm/Testcmd: Código de salida 1, Errores: 1, Advertencias: 1 dalsa.pas(157,3) Warning: Comment level 2 found Linking /home/jorge/Documentos/git/Lazarus-Dalsa/bin/linux-arm/Testcmd /home/jorge/fpcupdeluxe/fpcupdeluxe/cross/bin/arm-linux/arm-linux- gnueabihf-ld: cannot find -lGevApi Testcmd.lpr(76,1) Error: Error while linking I think the compiler is searching for the library. I got the library for arm. I tried to include in compiler options/path, but I got this error: Quote./armlib//libGevApi.so: file not recognized: file format not recognized , but I don't how to include in my proyect. Thanks for your help /BlueIcaro ---------------------------------------------------------------------- DonAlfredo · 2020-10-28 11:07 Put the correct libGevApi.so in /home/jorge/fpcupdeluxe/fpcupdeluxe/cross/lib/arm-linux And with correct I mean: I guess that libGevApi.so is just a symlink. You will need the library itself, not the symlink. ---------------------------------------------------------------------- PascalDragon · 2020-10-28 12:26 Quote from: DonAlfredo on October 28, 2020, 12:07:21 pmPut the correct libGevApi.so in /home/jorge/fpcupdeluxe/fpcupdeluxe/cross/lib/arm- linux And with correct I mean: I guess that libGevApi.so is just a symlink. You will need the library itself, not the symlink. Symlinks are correctly handled by ld. Quote from: BlueIcaro on October 28, 2020, 11:48:37 amI think the compiler is searching for the library. I got the library for arm. I tried to include in compiler options/path, but I got this error: Quote./armlib//libGevApi.so: file not recognized: file format not recognized , but I don't how to include in my proyect. You need to add the path where the library resides in with -Fl.... Would you also please provide the output of file /path/to/libGevApi.so? ---------------------------------------------------------------------- BlueIcaro · 2020-11-03 15:32 BTW, I make a mistake in my first post, the cpu target is aarch64. QuoteWould you also please provide the output of file /path/to/libGevApi.so? I don't know what is it?. Give me some instructions to provide that info to you. /BlueIcaro Edit: PascalDragron do you want to say the output when I try to compile?. I got this info from console QuoteHint: (lazarus) Project needs building: Compile was incomplete for Project [TCompiler.Compile] CmdLine="/home/jorge/fpcupdeluxe/fpcupdeluxe/fpc/b in/x86_64-linux/fpc.sh  -Tlinux -Paarch64 -MObjFPC -Scghi -CX -O3 -XX -l -vewnhibq -Fi/home/jorge/Documentos/git/Lazarus- Dalsa/lib/aarch64-linux -Fl/home/jorge/Documentos/git/Lazarus- Dalsa/armlib/lib/lib -Fu/home/jorge/Documentos/git/Lazarus-Dalsa/ -FU/home/jorge/Documentos/git/Lazarus-Dalsa/lib/aarch64-linux/ -FE/home/jorge/Documentos/git/Lazarus-Dalsa/bin/linux-aarch64/ -o/home/jorge/Documentos/git/Lazarus-Dalsa/bin/linux-aarch64/Testcmd Testcmd.lpr" Info: (lazarus) Execute Title="Compilar proyecto, Modo: jetson, CPU: aarch64, Objetivo: bin/linux-aarch64/Testcmd" Info: (lazarus) Working Directory="/home/jorge/Documentos/git/Lazarus- Dalsa/" Info: (lazarus) Executable="/home/jorge/fpcupdeluxe/fpcupdeluxe/fpc/bi n/x86_64-linux/fpc.sh" Info: (lazarus) Param[0]="-Tlinux" Info: (lazarus) Param[1]="-Paarch64" Info: (lazarus) Param[2]="-MObjFPC" Info: (lazarus) Param[3]="-Scghi" Info: (lazarus) Param[4]="-CX" Info: (lazarus) Param[5]="-O3" Info: (lazarus) Param[6]="-XX" Info: (lazarus) Param[7]="-l" Info: (lazarus) Param[8]="-vewnhibq" Info: (lazarus) Param[9]="-Fi/home/jorge/Documentos/git/Lazarus- Dalsa/lib/aarch64-linux" Info: (lazarus) Param[10]="-Fl/home/jorge/Documentos/git/Lazarus- Dalsa/armlib/lib/lib" Info: (lazarus) Param[11]="-Fu/home/jorge/Documentos/git/Lazarus- Dalsa/" Info: (lazarus) Param[12]="-FU/home/jorge/Documentos/git/Lazarus- Dalsa/lib/aarch64-linux/" Info: (lazarus) Param[13]="-FE/home/jorge/Documentos/git/Lazarus- Dalsa/bin/linux-aarch64/" Info: (lazarus) Param[14]="-o/home/jorge/Documentos/git/Lazarus- Dalsa/bin/linux-aarch64/Testcmd" Info: (lazarus) Param[15]="Testcmd.lpr" [TCompiler.Compile] end Hint: (lazarus) [TMainIDE.DoBuildProject] compiler time in s: 0,135000399313867 Error: (lazarus) [TMainIDE.DoBuildProject] Compile failed ---------------------------------------------------------------------- PascalDragon · 2020-11-04 08:22 No, I meant what I said: Code: [Select]$> file /path/to/libGevApi.so E.g. on my system for libc it will look like this: Code: [Select]sb@Merkur:~$ file /lib/x86_64-linux-gnu/libc-2.27.so /lib/x86_64-linux-gnu/libc-2.27.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=d3cf764b2f97ac3efe366ddd07ad902fb6928fd7, for GNU/Linux 3.2.0, stripped Nevertheless regarding the output you provided: is the path to your libGevApi.so part of the paths listed there with -Fl? ---------------------------------------------------------------------- BlueIcaro · 2020-11-04 17:34 Hi, file comand returns this: Quotefile /usr/local/lib/libGevApi.so /usr/local/lib/libGevApi.so: symbolic link to /usr/local/lib/libGevApi.so.2 After put libGevApi.so in the path -Fl, I make a small step. Because I got a lot of warnings, and after a new linking error: Quote/home/jorge/fpcupdeluxe/fpcupdeluxe/cross/bin/arm-linux/arm- linux-gnueabihf-ld: warning: libCorW32.so.1, needed by ./LibPi//libGevApi.so, not found (try using -rpath or -rpath-link) /home/jorge/fpcupdeluxe/fpcupdeluxe/cross/bin/arm-linux/arm-linux- gnueabihf-ld: warning: libGenApi_gcc46_v3_0.so, needed by ./LibPi//libGevApi.so, not found (try using -rpath or -rpath-link) /home/jorge/fpcupdeluxe/fpcupdeluxe/cross/bin/arm-linux/arm-linux- gnueabihf-ld: warning: libGCBase_gcc46_v3_0.so, needed by ./LibPi//libGevApi.so, not found (try using -rpath or -rpath-link) So I add all library that I found in the compiler messages. But I couldn't solve the last one. This: Quote/home/jorge/fpcupdeluxe/fpcupdeluxe/cross/bin/arm-linux/arm- linux-gnueabihf-ld: ./LibPi//libGevApi.so: undefined reference to `fcntl@GLIBC_2.28' /BlueIcaro ---------------------------------------------------------------------- DonAlfredo · 2020-11-04 18:32 You are doing good !  However. You have now encountered a more difficult problem. Let me explain. You are cross-compiling towards linux-arm. This OS has its own libs with its own versions of glibc and other libraries. To allow you to cross-compile, fpcupdeluxe has downloaded its own, more or less general Linux arm libs. I just had a look at the GNU C Library: Ubuntu GLIBC 2.24. Older than the libs you need to link against your own version of libGevApi. So, you have a version mismatch. Replace all cross arm-linux libs from fpcupdeluxe with libs from your own system. You will be certain that your app will work on your system. With the right versions. Brute force: Delete all fpcupdeluxe libs. Copy all the libs from your arm-system /lib and usr/lib. Thats a lot, but will work.