Dynamic linking is not working with the firmware library

I downloaded the libjson.so library to the musl cross compile environment (/usr/aarch64-linux-gnu//musl), which has the layout as the following:

/usr/aarch64-linux-gnu/
├── bin
├── include
│   ├── arpa
│   └── ...
├── lib
│   ├── audit
│   ├── gconv
│   └── ldscripts
├── lib64
├── musl
│   ├── include
│   └── lib
└── usr
    └── bin

I also downloaded the header files to the include folder. However, I cannot compile my program:

[u@archlinux tmp.UZIJgdZKC7]$ musl-gcc t.c -ljson-c
/usr/lib/gcc/aarch64-linux-gnu/13.2.0/../../../../aarch64-linux-gnu/bin/ld: /usr/aarch64-linux-gnu/musl/lib/libjson-c.so: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status

What might be the problem? Is it because the section headers were removed in the library?

/usr/aarch64-linux-gnu/musl/lib/libjson-c.so.5.2.0: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, no section header

Yes. Shared objects are aggressively stripped, including section headers crucial for linking. You can’t use the artifacts from the firmware rootfs for this purpose.

Thanks, does openwrt provide any rootfs that can be used for developing?

No, you would need to use the SDK or buildroot to compile desired libraries.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.