Buildroot adding custom libraries originating from FPC

0

I have a buildroot project in which I want to add a library compiled with pascal. The reason for this is that it is a custom library and porting it to C is too much work at this point. I am compiling it for a raspberry pi CM3. How it currently works:

  1. I have compiled the library libcustom.so on an raspberry pi (raspbian).
  2. In buildroot I download the library from a git repository.

Now the problem I have is that the program that used this library cannot find the library (although it is in the /usr/lib/ folder). Using the ldd command I got the following output:

$ ldd /usr/lib/libcustom.so
checking sub-depends for 'not found'
checking sub-depends for 'not found'
checking sub-depends for 'not found'
    ld-linux-armhf.so.3 => not found (0x00000000)
    libdl.so.2 => not found (0x00000000)
    libc.so.6 => not found (0x00000000)
    not a dynamic executable

By checking the output given by the same command on the system where I compiled the library helped me to resolve which sub-depends were missing. Since the architecture of both the systems is the same I figured that to test what is missing I could simply copy the libraries from the compilation system to the buildroot system. (libraries that were missing were libc.so.6,libdl.so.2 and lib-linux-armhf.so.3). Now ldd gives me the following:

$ ldd /usr/lib/libcustom.so
checking sub-depends for '/lib/ld-linux-armhf.so.3'
checking sub-depends for '/usr/lib/libdl.so.2'
checking sub-depends for '/usr/lib/libc.so.6'
    /lib/ld-linux-armhf.so.3 (0x76fc2000)
    linux-vdso.so.1 (0x7ef00000)
checking sub-depends for '/usr/lib/libc.so.6'
    /lib/ld-linux-armhf.so.3 (0x76ee8000)
    linux-vdso.so.1 (0x7efeb000)
    /lib/ld-linux-armhf.so.3 => /lib/ld-linux-armhf.so.3 (0x00000000)
    libc.so.6 => /usr/lib/libc.so.6 (0x00000000)
    /lib/ld-linux-armhf.so.3 => /lib/ld-linux-armhf.so.3 (0x00000000)

The custom library is still not working (and the ldd still points to empty (0x00000000) libraries.


I have been searching around a bit however there are still two things that I do not understand:

  1. Why is the above solution not working? The libraries are the same architecture but as ldd points out above, some libraries still cannot be properly found.
  2. How can I include libraries in buildroot? I have been searching for this and found how to add custom packages, but I am still clueless about how to add specific libraries (such as the one I have added by hand).
libraries
freepascal
buildroot
ldd
asked on Stack Overflow Jun 25, 2018 by Steven

2 Answers

1

You can't take a library built on system A (Raspbian) and automagically expect this library to work on system B (built with Buildroot). Indeed the C library may be different, and the ABI may be different. Compatibility at the binary level is not trivial.

You've got two options here:

  • Make sure the Buildroot configuration matches the libc/ABI used on Raspbian. In your case, it seems like building a glibc toolchain in Buildroot with the EABIhf ABI should do the trick.

  • Build your library with Buildroot. That will require creating a package for a Pascal cross-compiler, and then a package for your library.

answered on Stack Overflow Jul 1, 2018 by Thomas Petazzoni
0

Is the distribution of both systems the same? Otherwise attempt to build the library cross with libraries from target.

answered on Stack Overflow Jun 25, 2018 by Marco van de Voort

User contributions licensed under CC BY-SA 3.0