Problems building Android 64 bits with IL2CPP

Hi!

I’m trying to build my project using IL2CPP in order to support Android 64 bits architecture.

My project has some native dependencies provided as static libraries.

I’m facing an undefined reference linker problem in the final stage of the IL2CPP process.

I suspect there is a problem with the STL version chosen by IL2CPP process, mostly because it may be different that the one I built my native libraries with.

std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, addrinfo*>, 
std::__ndk1::__unordered_map_hasher<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, 
std::__ndk1::allocator<char> >, std::__ndk1::__hash_value_type<std::__ndk1::basic_string<char, 
std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, addrinfo*>, 
std::__ndk1::hash<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > >, true>, std::__ndk1::__unordered_map_equal<std::__ndk1::basic_string<char, 
std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, 
std::__ndk1::__hash_value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, 
std::__ndk1::allocator<char> >, addrinfo*>, std::__ndk1::equal_to<std::__ndk1::basic_string<char, 
std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > >, true>, 
std::__ndk1::allocator<std::__ndk1::__hash_value_type<std::__ndk1::basic_string<char, 
std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, addrinfo*> > >::rehash(unsigned long)':

/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/__hash_table:2142: 
undefined reference to `std::__ndk1::__next_prime(unsigned long)'```

Do you have any clue?

I was trying to investigate how to customize IL2CPP process but it looks like there is no setup parameter in the Unity editor.

Thanks in advance.

Adding some more details

I’ve just upgraded Unity to the latest 2019.1.11 build and now I see that IL2CPP is using gnu-libstdc++

...-L/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a" -lgnustl_static...

My native library requires llvm-c++ and that’s why I’m getting a linker error.

Is it possible to prompt IL2CPP to use a different STL implementation?

I’m still stuck on this.

Anyone has any suggestion?

Thanks!

Anyone can help on this?

Sadly, changing such setting is not exported, il2cpp uses gnu stl for NDK versions which are below 18.
As per this page Unity - Manual: Android environment setup 2019.1 and 2019.2 uses NDK 16.

But in 2019.3 Unity uses NDK 19, this is where newer STL will be used.

Thanks for the answer @Tomas1856

I was trying with last 2019.3 beta, and I’m having some issues with the linker process. It cannot find some symbols that should be included in the batch of .a files it is using :eyes:

In any case, I’m also getting some errors because my native code is using Open SL, and opensl is not included in the linking process.

Is there a way to specify which dynamic libraries the process will use?

Looking at the command it makes:

/Applications/Unity/Hub/Editor/2019.3.0b1/PlaybackEngines/AndroidPlayer/NDK/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ 
@"/var/folders/k5/d_k12cmj1xlgv611w2sbf4j00000gn/T/tmpeGtQiY.tmp" 
-o "/..../Library/il2cpp_android_arm64-v8a/il2cpp_cache/linkresult_EB7A7567D619CE892FFDBA33E398AC8C/libil2cpp.so" 
-shared -Wl,-soname,libil2cpp.so 
-Wl,--no-undefined -Wl,-z,noexecstack -Wl,--gc-sections -Wl,--build-id 
--sysroot "/Applications/Unity/Hub/Editor/2019.3.0b1/PlaybackEngines/AndroidPlayer/NDK/platforms/android-21/arch-arm64" 
-gcc-toolchain "/Applications/Unity/Hub/Editor/2019.3.0b1/PlaybackEngines/AndroidPlayer/NDK/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64" 
-target aarch64-none-linux-android -Wl,--wrap,sigaction -nostdlib++ 
-L "/Applications/Unity/Hub/Editor/2019.3.0b1/PlaybackEngines/AndroidPlayer/NDK/sources/cxx-stl/llvm-libc++/libs/arm64-v8a" "/mylib1.a" "/mylib2.a" "/mylib3.a" 
-lc++_static -lc++abi -llog -rdynamic -fuse-ld=bfd```

I will need to have a -l flag with opensl too

 @Tomas1856  do you know if that flag can be added somehow?

Again, this is not exposed, I would suggest to fill a bug report so we can investigate