freddy freddy - 3 months ago 11
Linux Question

Cross compilation: can't resolve symbol 'register_printf_function'

I have cross-compiled strongswan-5.2.2, a open source project implementing VPN server&client, for embedded-linux running on mipsel (target) on Ubuntu12.04 running on Intel x86 machine.

But executing the cross-compiled strongswan on mipsel machine fails as follows:

$ ./charon
./charon: can't resolve symbol 'register_printf_function'


It seems like that
libc.so
is not refereed by the executable. The reason why I think like that is
register_print_function
is implemented in
libc.so
(AFAIK). However,
libc.so
already exists on
/lib
of target mipsel machine.

Inspecting all of shared libraries referred by the executable shows:

$ readelf -d ./charon | grep NEEDED
0x000001 (NEEDED) Shared Library: [libm.so.0]
0x000001 (NEEDED) Shared Library: [libpthread.so.0]
0x000001 (NEEDED) Shared Library: [libdl.so.0]
0x000001 (NEEDED) Shared Library: [libgcc_s.so.1]
0x000001 (NEEDED) Shared Library: [libc.so.0]


All of the above libraries exist on
/lib
of target machine..

Why is that error message coming up, yet I have all of the shared libraries required by the executable on target machine? And... how can I solve the problem?

Update:

$ nm -D libc.so.0
...
0002fb70 T register_printf_fuction
...


That function is already implemented in the shared library, isn't it...?

Answer

register_printf_function is specific to GNU glibc. If your target machine has some other libc (e.g. dietlibc or musl-libc) it is not available.

you may compile glibc for your target machine (probably difficult) or find a strongswan specific workaround

Check with nm -D /lib/libc.so that the target libc has a register_printf_function

Comments