Search code examples
androidc++cross-compiling

What is causing c++ function signature to be different?


Our build machine is set up with an earlier version of Android NDK. Most of our code is built on this machine and the final Android image is created.

My development machine uses the latest version of Android NDK.

I am creating a static library from my C++ code on my development machine and copy it over to the build machine for final linking.

The problem is that the compiler on the two machines seem to differ on name mangling.

For example, for std::string, my dev machine produces this signature:

 std::__ndk1::basic_string<char, ...>

However, on the build machine, the expected signature is:

 std::__1::basic_string<char, ...>

I am trying to figure out if the android-gcc compiler using a different name-mangling scheme or if stl files themselves are different. If it is the first case, is there a way to enforce a different name-mangling scheme. Thanks.


Solution

  • There is no name mangling going on here. There seems to be two different standard libraries in use, one defines basic_string in an internal namespace called __ndk1, the other one in __1. This is basically an implementation detail. Make sure to use the same compiler and standard library implementation for these to match.

    P.S. std::basic_string is not a function, but a class template.