0
votes

I'm trying to build a shared library to use on a raspberry pi (model 3B) using lazarus. After some puzzling I found out that my original library didn't work properly so I switched to a very simple library using this example.

But even this simple library doesn't compile properly to be used. When I try to open the library in another lazarus project it gives me the error:

 < libName >: cannot open shared object file: No such file or directory 

After some research I found the following diagnostics I could run. The file and ldd command in the compile library:

$file ./libname.so gives:

./libname.so: ELF 32-bit LSB shared object, ARM, EABI5 verion 1 (SYSV), dynamically linked, not stripped

$ldd ./libname.so

not a dynamic executable

I have searched for similar cases and from found that others had this problem when they tried to use libraries compile for a different platform/architecture. I already set the project>project options>compiler options>target platform to OS:= linux and Target CPU family: arm.

The system I am using (using $uname -a):

Linux raspberrypi 4.4.13-V7+ #894 SMP Mon Jun 13 13:13:27 BST 2016 armv7l GNU/Linux

with distro: Raspbian GNU/linux 8.0 (jessie)

Lazarus version: 1.2.4+dfsg2-1 FPC version: 2.6.4 arm-linux-gtk2

At this point I am not sure what is wrong and why this library isn't working. I can find very little information on this problem (on the aspberry platform and using lazarus) Any suggestions what I could try to make it work, compile it different or do some more diagnostics?

1
And if you do LD_LIBRARY_PATH=., what happens then? Or try to import unit "initc" into your library.Marco van de Voort
Tried both, indeed the initc solved it, but resulted in another problem. However found a solution, which I will post. Thanks anyway!Steven

1 Answers

2
votes

Found the solution. As Marco proposed above: Add initc to the uses part. It seems that if you try to make a library it has to include initc, cmem or LCL to the uses section because the library has to do some memory management for which it needs one of these units.

However this resulted in another error when trying to load the library:

"Undefined symbol: TC_SYSTEM_ISLIBRARY"

This seems to be a raspberry specific problem, compilers on other systems do not give this error. More information can be found HERE.

Eventually solved this by install fpc 3.0.0 compiler on the raspberry pi, compiled it and the library can be loaded properly (but still needs one of the above units).