Lazarus
Programming => Operating Systems => Linux PDAs => Topic started by: DelphiDinosaur on December 01, 2021, 05:55:43 pm
-
After some time, I have FPC v3.2.2 and Lazarus 1.8.4 running on a Variscite arm. I can compile and run terminal apps quite happily.
I'm having trouble loading libraries. The attached code works fine on a Linux desktop PC (FPC 3.2.0 & Laz 2.0.12). However, the LoadLibrary function always returns 0 on the same code compiled on the arm.
Using nm -D on the .so lists the exported function on the arm compiled code.
I've used the LoadLibrary function for years on Delphi 6 and XE3 so don't believe there's anything fundamentally wrong with the code. I suspect it's a magic rune in Linux that needs setting.
Any suggestions?
-
Attached is my own library loader, which you might find useful as a known-working example. It underpins the code at e.g. https://github.com/MarkMLl/asound
MarkMLl
-
I'm having trouble loading libraries. The attached code works fine on a Linux desktop PC (FPC 3.2.0 & Laz 2.0.12). However, the LoadLibrary function always returns 0 on the same code compiled on the arm.
What does GetLoadErrorStr return? What options did you use to compile both the program and the library?
-
What does GetLoadErrorStr return? What options did you use to compile both the program and the library?
GetLoadErrorStr returns "can't open shared object file: No such file or directory", and includes the exact path to the .so (path case matches). The earlier line checking FileExists finds the file.
The same code works with a third party .so saved in the same location so I'm confident it's not the calling program that's the problem.
The library file is compiled with the standard settings when Lazarus starts a new Library project. Any suggestions as to what may need changing?
DD.
-
Found the answer on Stack Overflow (https://stackoverflow.com/questions/41459956/build-a-shared-library-on-a-raspberry-using-lazarus).
Added initc to the uses section was all that was needed.
Seemingly, cmem or LCL may also work but I haven't tried them.
Thanks for your time if you looked at this.
DD.
-
Found the answer on Stack Overflow (https://stackoverflow.com/questions/41459956/build-a-shared-library-on-a-raspberry-using-lazarus).
Added initc to the uses section was all that was needed.
Seemingly, cmem or LCL may also work but I haven't tried them.
Usually cmem right at the start of the uses list, followed if necessary by heaptrc, then by cthreads etc.
There's another gotcha with at least some versions of libusb, discussed and worked around in the example I posted.
MarkMLl