Search Unity

Fresh Ubuntu 18.04 installation, IL2CPP issue, missing libraries?

Discussion in 'Linux' started by senkal_, Dec 29, 2019.

  1. senkal_

    senkal_

    Joined:
    May 22, 2018
    Posts:
    86
    Hi all,
    I just installed fresh Ubuntu 18.04 to have the best possible support for Unity on Linux.
    I almost got everything right for mobile development apart from IL2CPP on Android.

    I installed Unity 2019.2.17 with option to install Unity provided libraries for JAVA/NDK/SDK, with some workaround mentioned here(https://issuetracker.unity3d.com/is...se-andriod-ndk-and-sdk-tool-installed-via-hub).
    In the end, Unity detects SDK, JDK and NDK just fine and can build apk package with Mono no problem.
    For NDK I used the one Unity downloaded package but had to fix the invalid directory it was downloaded to.
    I use .Net 4.x, tried to build AMRv7 and ARM64, and with NDK the issue is the same.

    Whenever I try to build Android package using IL2CPP I get:
    Code (CSharp):
    1. Failed running /home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/il2cpp/build/il2cpp.exe --convert-to-cpp --emit-null-checks --enable-array-bounds-check --dotnetprofile="unityaot" --compile-cpp --libil2cpp-static --platform="Android" --architecture="ARMv7" --configuration="Release" --outputpath="/home/marcin/Workspace/games/test 2019.2.17/Temp/StagingArea/assets/bin/Data/Native/armeabi-v7a/libil2cpp.so" --cachedirectory="/home/marcin/Workspace/games/test 2019.2.17/Assets/../Library/il2cpp_android_armeabi-v7a/il2cpp_cache" --additional-include-directories="/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools/bdwgc/include" --additional-include-directories="/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools/libil2cpp/include" --tool-chain-path="/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK" --profiler-report --map-file-parser="/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/Tools/MapFileParser/MapFileParser" --directory="/home/marcin/Workspace/games/test 2019.2.17/Temp/StagingArea/assets/bin/Data/Managed" --generatedcppdir="/home/marcin/Workspace/games/test 2019.2.17/Temp/StagingArea/Il2Cpp/il2cppOutput"
    When I try to run the command in terminal manually I get some more readable error output:

    Code (CSharp):
    1. /home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/il2cpp/build/il2cpp.exe --convert-to-cpp --emit-null-checks --enable-array-bounds-check --dotnetprofile="unityaot" --compile-cpp --libil2cpp-static --platform="Android" --architecture="ARMv7" --configuration="Release" --outputpath="/home/marcin/Workspace/games/test 2019.2.17/Temp/StagingArea/assets/bin/Data/Native/armeabi-v7a/libil2cpp.so" --cachedirectory="/home/marcin/Workspace/games/test 2019.2.17/Assets/../Library/il2cpp_android_armeabi-v7a/il2cpp_cache" --additional-include-directories="/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools/bdwgc/include" --additional-include-directories="/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools/libil2cpp/include" --tool-chain-path="/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK" --profiler-report --map-file-parser="/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/Tools/MapFileParser/MapFileParser" --directory="/home/marcin/Workspace/games/test"
    2.  
    3. bash: /home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/il2cpp/build/il2cpp.exe: cannot execute binary file: Exec format error
    4.  
    From what I read "Exec format error" is related to issue with cpu type invalid versions (arm/32 bit/64 bit etc).
    I am not sure what is wrong here but I assume that I miss some libraries which would allow me to build Android IL2CPP using NDK.
    What I have installed is build-essentials plus some libraries like
    libc6:i386 libstdc++6:i386
    libgtk2.0-0 libsoup2.4-1 libarchive13 libpng16-16 libgconf-2-4 lib32stdc++6 libcanberra-gtk-module
    This is the list I found somewhere on the internet. Unfortunately it didn't help.
    Any clues?
     
  2. andrews_unity

    andrews_unity

    Unity Technologies

    Joined:
    Dec 11, 2015
    Posts:
    264
    Do you have mono installed ?
     
  3. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,675
    Can you paste the contents of the editor log?
     
  4. senkal_

    senkal_

    Joined:
    May 22, 2018
    Posts:
    86
    Thank you for fast feedback, didn't expect it :)

    @andrews_unity
    I didn't install any mono related packages until now.
    I just installed mono-runtime, but unfortunately it didn't help.
    Probably this is not the right thing to install but I am not sure which mono related thing can fix it.
    If you know where I can find list of packages which are required I am more than happy to follow that.

    @Tautvydas-Zilys
    I am attaching Editor.log right after I installed mono-runtime and built sample scene(got expected error).

    Again, thank you for answers.

    [Update]
    I later also installed mono-devel(thank you Rider) but it didn't change anything.
     

    Attached Files:

    Last edited: Dec 31, 2019
  5. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,675
    So it looks like IL2CPP failed to run clang from the NDK installation directory:

    Code (csharp):
    1. System.ComponentModel.Win32Exception:
    2. ApplicationName='/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/clang', CommandLine='-DNET_4_0 -DUNITY_AOT -DIL2CPP_MONO_DEBUGGER_DISABLED -DGC_NOT_DLL -DRUNTIME_IL2CPP -DLINUX -DANDROID -DPLATFORM_ANDROID -D__linux__ -D__STDC_FORMAT_MACROS -I"/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools/bdwgc/include" -I"/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools/libil2cpp/include" -I"/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/il2cpp/libil2cpp" -I"/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/il2cpp/libil2cpp" -I"/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/il2cpp/external/bdwgc/include" -I"/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/il2cpp/external/xxHash" -I"/home/marcin/Workspace/games/test 2019.2.17/Temp/StagingArea/Il2Cpp/il2cppOutput" -I"." -I"/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/sources/cxx-stl/gnu-libstdc++/4.9/include" -I"/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/sources/cxx-stl/gnu-libstdc++/4.9/include/backward" -I"/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include" -c -g -DNDEBUG -fexceptions -fno-limit-debug-info -fdata-sections -ffunction-sections -Wa,--noexecstack -fno-rtti -fno-strict-aliasing -fvisibility=hidden -fvisibility-inlines-hidden -fno-strict-overflow -fPIC -Os --sysroot "/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/sysroot" -gcc-toolchain "/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64" -target armv7-none-linux-androideabi -isystem "/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/sysroot/usr/include/arm-linux-androideabi" -D__ANDROID_API__=16 -march=armv7-a -mfloat-abi=softfp -mfpu=neon-fp16 -Wno-unused-value "/home/marcin/Workspace/games/test 2019.2.17/Temp/StagingArea/Il2Cpp/il2cppOutput/Il2CppMetadataUsage.c" -o "/home/marcin/Workspace/games/test 2019.2.17/Library/il2cpp_android_armeabi-v7a/il2cpp_cache/0EAD674A7C1BE2ADE2882110064E0261.o"'
    3. CurrentDirectory=''
    4. Native error= Access denied
    Is the file there? If it is, does it have the executable bit set?
     
  6. senkal_

    senkal_

    Joined:
    May 22, 2018
    Posts:
    86
    Thanks @Tautvydas-Zilys for help

    bin clang directory binaries didn't have execute permission, fixed(should it be reported separately?).
    Unfortunately now there is another issue, I guess important part(new Editor.log attached)


    Code (CSharp):
    1. home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ @"/tmp/tmp5e750f76.tmp" -o "/home/marcin/Workspace/games/test 2019.2.17/Library/il2cpp_android_armeabi-v7a/il2cpp_cache/linkresult_5B31CF606F193D11483E7D02161C2595/libil2cpp.so" -shared -Wl,-soname,libil2cpp.so -Wl,--no-undefined -Wl,-z,noexecstack -Wl,--gc-sections -Wl,--build-id --sysroot "/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/platforms/android-16/arch-arm" -gcc-toolchain "/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64" -target armv7-none-linux-androideabi -Wl,--wrap,sigaction -L "/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a" -lgnustl_static -latomic -llog -rdynamic -fuse-ld=gold
    2.  
    3. /usr/bin/ld.gold: fatal error: /home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/platforms/android-16/arch-arm/usr/lib/../lib/crtbegin_so.o: unsupported ELF machine number 40
    4. clang++: error: linker command failed with exit code 1 (use -v to see invocation)
    Update
    I tried to build AMRv7(log above and Editor.log).
    When I try to build AMR64 this part is a little different, what I get:

    Code (CSharp):
    1. il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException: /home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ @"/tmp/tmp767af960.tmp" -o "/home/marcin/Workspace/games/test 2019.2.17/Library/il2cpp_android_arm64-v8a/il2cpp_cache/linkresult_18B639A856F981E6C6C8FFCF00A937FD/libil2cpp.so" -shared -Wl,-soname,libil2cpp.so -Wl,--no-undefined -Wl,-z,noexecstack -Wl,--gc-sections -Wl,--build-id --sysroot "/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/platforms/android-21/arch-arm64" -gcc-toolchain "/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64" -target aarch64-none-linux-android -Wl,--wrap,sigaction -L "/home/marcin/Unity/Hub/Editor/2019.2.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a" -lgnustl_static -latomic -llog -rdynamic -fuse-ld=bfd
    2.  
    3. /usr/bin/ld.bfd: unrecognised emulation mode: aarch64linux
    4. Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu i386linux elf_l1om elf_k1om i386pep i386pe
    5. clang++: error: linker command failed with exit code 1 (use -v to see invocation)
    6.  
     

    Attached Files:

    Last edited: Dec 30, 2019
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,675
    That falls beyond my knowledge, unfortunately... I'll ask somebody who knows about android toolchains to respond.
     
  8. senkal_

    senkal_

    Joined:
    May 22, 2018
    Posts:
    86
    @Tautvydas-Zilys no worries, I am really grateful for the time you invested already.
    Will try maybe to download NDK separately and use that one instead of NDK provided by Unity.
     
  9. senkal_

    senkal_

    Joined:
    May 22, 2018
    Posts:
    86
    I switched to freshly downloaded android-ndk-r16b and ... no more issues.
    I don't know what is changed in the Unity version of the NDK, is it just more permissions issues?
    For now will stick with the tools not provided by Unity.
     
    Yury-Habets and comealong like this.
  10. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    @senkal_ thanks for reporting this. We'll check it and get back to you.
     
    Last edited: Jan 9, 2020
    senkal_ likes this.
  11. AlexisLeclerc

    AlexisLeclerc

    Joined:
    Nov 3, 2018
    Posts:
    2
    I confirm, same problem and same solution here
    Unity 2019.2.20f1, Ubuntu 18.04
     
  12. oracle1124

    oracle1124

    Joined:
    Feb 23, 2020
    Posts:
    1
    I am on 2019.3 and Ubuntu 19.10, and have spent hours trying to build on Android with no luck, why is it so complicated?

    Currently, I am stuck with the built in tools complaining about "/usr/bin/ld.bfd: unrecognised emulation mode: aarch64linux"

    Trying external tools, I cannot even get the SDK/NDK to detect properly or yet alone even running

    (Edit: oh yeah, also the editor becomes unable to close after a build failure, which makes me resort to find it and manually killing from a terminal)