SQLite - Can not load SQLite client library lazarus / 16-Databases ---------------------------------------------------------------------- Mark20 · 2022-12-15 20:47 Hi, I have a strange problem loading the SQLite client library; Running my console TestProgram on RaspberryPi4  it work smoothly, load the "libsqlite3.so" library and show the first 10 records. But when I run the same program on a SingleBoardComputer of type armv7l  with GNU/Linux I get the load error... 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 root@w ~#root@w ~# ./TestProgram*** Start ***Program Directory: /root/Sqlite library: /root/libsqlite3.so An unhandled exception occurred at $000E3750:EInOutError: Can not load SQLite client library "/root/libsqlite3.so". Check your installation.  $000E3750  $000E3640  $00051460  $000108CC  main,  line 26 of TestProgram.pas root@w ~#  I am using the TSQLDBLibraryLoader component to load the library, and before   SQLDBLibraryLoader1.Enabled := True; I print the path to be sure where I search the lib file. But the error raise only on the SBC and not on Rpi4. Both are 32bit OS version. Anyone have had similar experience or any idea ? Thank you. ---------------------------------------------------------------------- af0815 · 2022-12-15 21:23 a ) Can you locate where the lib in real is ? /root/libsqlite3.so looks not linuxlike.  b ) Is the library for your system. Have you installed the library with the tools of the SingleBoardComputer system ? ---------------------------------------------------------------------- Mark20 · 2022-12-16 22:09 hi a) yes I have loaded the lib and DB file in the same folder, together with my test program. As they are in the Raspbery folder.     Addes the execution atttribute. b) the library is loaded is the one available on Rpi for SQLite. About SBC I have no docs...  I know only that it's an "armv7l" 32 bit,     same as Rpi, and the console applications compiled on Rpi, run well also on this SBC.     I dont' know about "Board specific installation tools for a library"...   copying the lib file is not enough ? ---------------------------------------------------------------------- af0815 · 2022-12-17 08:27 copying a lib in the same folder is not a good idea on linux systems. Linux based systems have special folder where the libs should placed and found by the library loader ld. It can be the lib need other libs, eg. for utf8 support. This is the reason for the installing with apt on the RasPi and should done on the SBC in the same way. Install/Copy the sqite tools on the SBC this should be done for a test, if this works, a programm compiled with Lazarus/FPC should also work. ---------------------------------------------------------------------- dbannon · 2022-12-17 09:11 I guess its already been checked but just in case... Your raspberry pi 4 could be running a 32bit or 64bit OS, are you sure the library you are using is in fact 32 bit ? Next, as mentioned above, *unix systems expect their libraries to be in specific (but configurable) places. Move or symlink it to one of those OS dependent, places. Look to see where other libraries are .... Davo ---------------------------------------------------------------------- Mark20 · 2022-12-19 08:50 Thank you both, I tried to install SQLite with APT but there is no such command on the SBC system... Anyway I didn't know, and have to study, about the way to install libs in linux systems. I have no docs so I'll try to understand the rules to be use here... Rpi is for sure a 32 bit, and the second should be, because the command  uname -a give this result    Linux w 4.1.15 #1 SMP PREEMPT Thu Jul 29 19:27:37 CST 2021 armv7l GNU/Linux and I read that  "armv7l"  means a 32bit system (?). Marko ---------------------------------------------------------------------- Чебурашка · 2022-12-19 09:00 Try the following command line on a console: user@somewhere>LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root     /root/TestProgram This should append to LD_LIBRARY_PATH your /root before running your executable, and this should be enough to make the .so findable. This can be useful to make tests with custom libraries before placing them in the default library directories that respect the linux filesystem standards. ---------------------------------------------------------------------- Thaddy · 2022-12-19 13:33 RPi is also AARCH64.albeit a pre-release. ---------------------------------------------------------------------- dbannon · 2022-12-21 10:10 Quote from: Thaddy on December 19, 2022, 02:33:40 pmRPi is also AARCH64.albeit a pre-release. Thaddy, I am unsure of your meaning here. The AARCH64 RasPi has been available since 2016. From memory, a 3 or 4 is 64bit. Davo ---------------------------------------------------------------------- Thaddy · 2022-12-21 10:35 No the 64 bit official OS version is available since 2021/22. Good for servers, but slower in graphics atm, will be updated in a later release. My answer was not about the chipset, but about Rasbian. ---------------------------------------------------------------------- Mark20 · 2022-12-22 12:09 I have verified the library path used by this linux echo $LD_LIBRARY_PATH     /lib:/usr/lib:/opt/mx6ul/tslib-1.19/lib:/opt/mx6ul/qt- 5.9.7/lib:/opt/mx6ul/alsa-1.1.2/lib and put the lib and symlinks:    libsqlite3.so.0.8.6          libsqlite3.so             libsqlite3.so.0          in the folders /lib and then /usr/lib, but none of them made the lib loadable by my program... :-( Any idea about what I could still try ? ---------------------------------------------------------------------- af0815 · 2022-12-22 13:14 what shows "file libsqlite3.so" ---------------------------------------------------------------------- Mark20 · 2022-12-22 13:37 I did the same as found for other lib present; in the  /usr/lib   i put the symlink  libsqlite3.so which point to the file lib in /lib So the file content is: root@w lib# readlink libsqlite3.so ../../lib/libsqlite3.so.0.8.6 which I guess correct... ---------------------------------------------------------------------- rvk · 2022-12-22 14:09 Quote from: Mark20 on December 15, 2022, 09:47:11 pmCode: [Select]Program Directory: /root/ Sqlite library: /root/libsqlite3.so (...) EInOutError: Can not load SQLite client library "/root/libsqlite3.so". Check your installation. Is it still looking in /root for your libsqlite3.so? Why? Did you hardcode that path? Show the code of the program where you determine that (or where you print those lines). ---------------------------------------------------------------------- Mark20 · 2022-12-22 14:55 No, I am no more using the SQLDBLibraryLoader component, because didn't solve the problem. Of course on Rpi it worked well as  this last version without libloader. 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 procedure Tdm.DataModuleCreate(Sender: TObject);var  exePath: string;begin    exePath := ProgramDirectory;    writeln(#9'Program Directory: '+exePath +#13#10);    sqliteConn.DatabaseName := exePath + 'cpa2.db';     writeln(#9'Database: '+ sqliteConn.DatabaseName +#13#10);    writeln(#9'DB connecting...' +#13#10);    sqliteConn.Connected := True;    writeln(#9'DB connected.' +#13#10);end; This code rely (I guess) on the Linux system library path, and on Rpi works well. Just to test on Rpi, I have put  in /usr/local/lib  the symlink  libsqlite3.so  which points to libsqlite3.so.0.8.6 in /usr/lib/arm- linux-gnueabihf  and it works. If I rename the symlink libsqlite3.so (making it unavailable) I get the same error I get on the SBC Linux, with the same exact memory addresses listed. root@w ~# ./TestProgram *** START PROGRAM ***         Program Directory: /root/         Database: /root/cpa2.db         DB connecting... An unhandled exception occurred at $000E3604: EInOutError: Can not load SQLite client library "libsqlite3.so". Check your installation.   $000E3604   $000B6BF8   $00051434   $000108A4  main,  line 26 of TestProgram.pas root@w ~# ---------------------------------------------------------------------- af0815 · 2022-12-22 15:45 You get the same error if the libsqlite3.so is the wrong version for your target. If it is for the wrong arm version or the false bitness. This is the reason for check this with a stanard lib from the system and your used libsqlite3.so. Only if bitness and type is correct it can be used. ---------------------------------------------------------------------- Mark20 · 2022-12-22 16:31 But on Rpi4 I get the same load error, only when I explicitily make the symlink  libsqlite3.so unavailable, renaming it... I mean, I used the same rules to install the library on both system  (of course the paths are specific) but works only on Rpi. And the bitness on both systems I verified is 32 ... What do you mean for "check this with a standard lib from the system" ? ---------------------------------------------------------------------- rvk · 2022-12-22 21:13 What's the result of this on both systems? ldconfig -p | grep sqlite And this? cd / sudo find -name libsqlite3.so* ---------------------------------------------------------------------- Mark20 · 2022-12-22 21:44 ldconfig -p | grep sqlite on sys Rpi4: root@raspberrypi:/# root@raspberrypi:/# ldconfig -p | grep sqlite    libsqlite3.so.0 (libc6,hard-float) => /usr/lib/arm-linux- gnueabihf/libsqlite3.so.0    libsqlite3.so.0 (libc6,hard-float) => /usr/local/lib/libsqlite3.so.0    libsqlite3.so (libc6,hard-float) => /usr/local/lib/libsqlite3.so root@raspberrypi:/# on sys SBC: root@w ~# ldconfig -p | grep sqlite -sh: ldconfig: not found root@w ~# find libsqlite3.so* on sys RPi4: root@raspberrypi:/# find -name libsqlite3.so* find: ‘./run/user/1000/gvfs’: Permission denied ./usr/lib/arm-linux-gnueabihf/libsqlite3.so ./usr/lib/arm-linux-gnueabihf/libsqlite3.so.0 ./usr/lib/arm-linux-gnueabihf/libsqlite3.so.0.8.6 ./usr/local/lib/libsqlite3.so.0 ./usr/local/lib/libsqlite3.so.0.8.6 ./home/pi/DevLZ/TestProgram/libsqlite3.so ./home/pi/DevLZ/TestProgram/libsqlite3.so.0.8.6 ./home/pi/DevLZ/TestProgram/tmp/libsqlite3.so.0.8.7 ./home/pi/DevLZ/TestForm/libsqlite3.so ./home/pi/DevLZ/TestForm/libsqlite3.so.0.8.6 ./home/pi/tmp/libsqlite3.so.0.8.6 ./home/pi/ustar/DevLZ/TestProgram/libsqlite3.so.0.8.6 ./home/pi/ustar/DevLZ/TestProgram/tmp/libsqlite3.so ./home/pi/ustar/DevLZ/TestProgram/tmp/libsqlite3.so.0 ./home/pi/ustar/DevLZ/TestProgram/tmp/libsqlite3.so.0.8.6 ./home/pi/ustar/DevLZ/TestProgram/tmp/libsqlite3.so.0.8.7 ./home/pi/ustar/DevLZ/TestForm/libsqlite3.so ./home/pi/ustar/DevLZ/TestForm/libsqlite3.so.0.8.6 root@raspberrypi:/# on sys SBC: root@w ~# find / -iname "libsqlite3.so*" /usr/lib/libsqlite3.so /lib/libsqlite3.so.0.8.6 /lib/libsqlite3.so.0 /root/libsqlite3.so /root/libsqlite3.so.0.8.6 /root/libsqlite3.so.0 root@w ~# The SBC is a FETMX6X-C System on Module:  https://www.forlinx.net/product/imx6quad-30.html ---------------------------------------------------------------------- rvk · 2022-12-22 21:54 What are those libsqlite3's doing in /root? Remove them. The ones in /usr/lib should be (automatically) used. What does this say? sudo ls -ltr /usr/lib/libsqlite3* sudo ls -ltr /lib/libsqlite3* ---------------------------------------------------------------------- af0815 · 2022-12-22 21:58 The question is, it a ARMEL or ARMHF Taget (ARMV5 vs. ARMV7). And for what kind of target are your libs. ---------------------------------------------------------------------- Mark20 · 2022-12-22 22:04 I added those in root, because in my last test I tryed again to use the SQLDBLibraryLoader  component; I deleted all other sqlite3 except in root and it worked again, but not on the SBC... root@w ~# ls -ltr /usr/lib/libsqlite3* lrwxrwxrwx    1 root     root            29 Dec 22 12:26 /usr/lib/libsqlite3.so -> ../../lib/libsqlite3.so.0.8.6 root@w ~# root@w ~# ls -ltr /lib/libsqlite3* -rwxrwxrwx    1 root     root       1014684 Dec 22 12:20 /lib/libsqlite3.so.0.8.6 lrwxrwxrwx    1 root     root            19 Dec 22 12:30 /lib/libsqlite3.so.0 -> libsqlite3.so.0.8.6 root@w ~# ---------------------------------------------------------------------- Mark20 · 2022-12-22 22:12 SBC is based on NXP i.MX6 processor family and both Rpi and i.MX6 should be "armv7l" type 32 bit, I guess... ---------------------------------------------------------------------- rvk · 2022-12-22 22:22 Looks ok. You could check file /lib/libsqlite3.so.0.8.6 ---------------------------------------------------------------------- rvk · 2022-12-22 22:24 I take it you installed both sqlite3 and libsqlite3-dev? ---------------------------------------------------------------------- Mark20 · 2022-12-23 08:32 No, I just copied my program, the database file and the libsqlite3.so.0.8.6 that is present on my Rpi4 and created the symlinks as you have seen. I tryed to install Sqlite, but on the SBC the APT-GET command is not available... There is DPKG command but no idea how use it and where find the proper Sqlite installation files... Can you give me any link ?   on their webiste I do not see a 32bit ARM version... Thank you ---------------------------------------------------------------------- af0815 · 2022-12-23 15:43 Mark20, you have never tried the file command on a library original on your SBC. This should tell what kind of type  it is. After then you can use find for the libsqlite3.so.0.8.6 file. Both must have the same type. Without the exact knowledge aof the system type it is impossible to look for the correct version. ---------------------------------------------------------------------- Mark20 · 2022-12-23 16:08 Sorry Andreas, It's not clear to me what you mean for  "you have never tried the file command on a library original on your SBC" Can you detail what kind of check do you expect I do on the SBC ? About the SBC I have these info: root@w ~# uname Linux root@w ~# uname -m armv7l root@w ~# uname -a Linux w 4.1.15 #1 SMP PREEMPT Thu Jul 29 19:27:37 CST 2021 armv7l GNU/Linux root@w ~# ---------------------------------------------------------------------- af0815 · 2022-12-23 16:27 rvk and i have not asked about the results of uname. --- Edit ---- I have found some articles about the armv7l. It can be the drivers for armv7 not working on a armv7l. Because some features are not supported by the armv7l. But it is compatible with armv6. And it looks, you are not alone with problems with sqlite on this target. ---------------------------------------------------------------------- rvk · 2022-12-23 16:46 Quote from: Mark20 on December 23, 2022, 09:32:18 amNo, I just copied my program, the database file and the libsqlite3.so.0.8.6 that is present on my Rpi4 and created the symlinks as you have seen.Are you sure all dependencies for libsqlite3 are installed? Just copying the one file isn't enough if the dependencies are not in place. For example... apt-cache showpkg libsqlite3-dev shows QuoteDependencies: 3.27.2-3+deb10u2 - libsqlite3-0 (5 3.27.2-3+deb10u2) libc6-dev (0 (null)) sqlite3-doc (0 (null))Is libc6-dev installed on your SBC?? (That's why installing is better than just coping some files. Dependencies will be resolved automatically.) Quote from: Mark20 on December 23, 2022, 09:32:18 amI tryed to install Sqlite, but on the SBC the APT-GET command is not available... There is DPKG command but no idea how use it and where find the proper Sqlite installation files...How do you install packages then? apt, yum, dnf or any other package manager? https://www.makeuseof.com/apt-vs-dnf-vs-yum/ How do you update and upgrade this system for updated packages? BTW. If apt-get isn't available it's still possible that apt is. Does executing apt on a command line give you something? O, and what is the result of this? cat /etc/*-release ---------------------------------------------------------------------- Mark20 · 2022-12-23 17:16 @Andreas: interesting the problem of drivers for armv7 not working on a armv7l. But the command cat /proc/cpuinfo say that are both amrv7l apart  from details that I don't know. Rpi4 root@raspberrypi:/home/pi/ustar/DevLZ/TestProgram# cat /proc/cpuinfo processor   : 0 model name   : ARMv7 Processor rev 3 (v7l) BogoMIPS   : 108.00 Features   : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 CPU implementer   : 0x41 CPU architecture: 7 CPU variant   : 0x0 CPU part   : 0xd08 CPU revision   : 3 SBC root@w ~# cat /proc/cpuinfo processor       : 0 model name      : ARMv7 Processor rev 10 (v7l) BogoMIPS        : 3.00 Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpd32 CPU implementer : 0x41 CPU architecture: 7 CPU variant     : 0x2 CPU part        : 0xc09 CPU revision    : 10 @RVK: I agree it's better install the packages, but  this shrinked Linux embedded is without APT, YUM, DFN... Seems available DPKG only, but no idea what feed it... root@w ~# dpkg BusyBox v1.30.1 (2019-08-19 20:18:32 HKT) multi-call binary. Usage: dpkg [-ilCPru] [-F OPT] PACKAGE Install, remove and manage Debian packages         -i,--install    Install the package         -l,--list       List of installed packages         --configure     Configure an unpackaged package         -P,--purge      Purge all files of a package         -r,--remove     Remove all but the configuration files for a package         --unpack        Unpack a package, but don't configure it         --force-depends Ignore dependency problems         --force-confnew Overwrite existing config files when installing         --force-confold Keep old config files when installing root@w ~# root@w ~# root@w ~# cat /etc/*-release cat: can't open '/etc/*-release': No such file or directory root@w ~# root@w ~# root@w ~# find / -iname "libc6-dev" root@w ~# ---------------------------------------------------------------------- af0815 · 2022-12-23 17:26 You can move your deb packages from the RasPi and try to install it with dpkg. And you can look for the Command Line Shell of sqlite. https://sqlite.org/cli.html . With this tool you can look if sqlite ist working before you make a try with Lazarus/fpc. ---------------------------------------------------------------------- rvk · 2022-12-23 18:02 You will also need any dependencies. What does this show? dpkg -l | grep libc6 And if libc6 isn't installed... (as it seems), You'll end up in a dependency hell (because libc6 and libc6-dev has a lot of dependencies itself.) Maybe you can install apt from a .deb file and let that take care if it (but you'll need to know the disto to make sure the correct files are installed). How (and from where) is the OS installed in the SBC? ---------------------------------------------------------------------- Mark20 · 2022-12-23 20:36 I am Looking into Rpi4 packages to copy those of libsqlite and found: libsqlite3-0:armhf                    3.27.2-3+deb10u2                      armhf        SQLite 3 shared library libsqlite3-dev:armhf                  3.27.2-3+deb10u2                      armhf        SQLite 3 development files sqlite3                               3.27.2-3+deb10u2                      armhf        Command line interface for SQLite 3 sqlitebrowser                         3.10.1-2                              armhf        GUI editor for SQLite databases But these are already installed and I think with Dpkg I should use the original package file (?), which I don't know where find... I start thinking is a problem too complex to solve for my knowledge... Unfortunately no trace of libc6* The OS was installed by a subcontractor of the cinese manufactuer of this machine, so we had no useful informations until now... Could it be a possible workaround  to compile my application with Static linking of libsqlite3 ?