androidcundefined-symbol

When compiled c function from different platforms and got symbols in difference with __kernel__


I tried to compile open source library nmap for the android platform.

In ubuntu, I used ndk tookchain to build libnetutil and get libnetutil.a. With nm, I lookup symbol for fuction: int mac_cache_get(const struct sockaddr_storage *ss, u8 *mac); I got symbol _Z13mac_cache_getPK25__kernel_sockaddr_storagePh.

But on Mac, I use Android Studio to writed a simple android c++ demo and call the fuction mac_cache_get.

It will report undefined reference to mac_cache_get(sockaddr_storage const*, unsigned char*) link error.

With nm the .o file, it try to call the function with symbol: _Z13mac_cache_getPK16sockaddr_storagePh.

So the symbol has littel difference with _Z13mac_cache_getPK25__kernel_sockaddr_storagePh and _Z13mac_cache_getPK16sockaddr_storagePh.

I don't know whether the difference cause the link error, if yes, how to fix the difference?


Solution

  • I made a mistake to use the compiler for linux platform which will generate the symbol with kernel prefix for sockaddr_storage parameter.

    The compiler for android platform will generate the symbol without kernel prefix.

    Thanks for all.