コガネブログ

平日更新を目標にUnityやC#、Visual Studioなどのゲーム開発アレコレを書いていきます

【Unity】Unity 2018.2.7f1 で Android の IL2CPP ビルドしようとしたらエラーが発生して解決できなかった話

概要

Failed running C:\Program Files\Unity 2018.2.7f1\Editor\Data\il2cpp/build/il2cpp.exe --convert-to-cpp --emit-null-checks --enable-array-bounds-check --compile-cpp --libil2cpp-static --platform="Android" --architecture="ARMv7" --configuration="Release" --outputpath="【Unity プロジェクト】\Temp/StagingArea\assets\bin\Data\Native\armeabi-v7a\libil2cpp.so" --cachedirectory="【Unity プロジェクト】\Assets\..\Library\il2cpp_android_armeabi-v7a/il2cpp_cache" --additional-include-directories="C:\Program Files\Unity 2018.2.7f1\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\bdwgc/include" --additional-include-directories="C:\Program Files\Unity 2018.2.7f1\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\libil2cpp/include" --tool-chain-path="C:/android-ndk-r13b-windows-x86_64/android-ndk-r13b" --map-file-parser="C:\Program Files\Unity 2018.2.7f1\Editor\Data\Tools\MapFileParser\MapFileParser.exe" --assembly="【Unity プロジェクト】\Temp\StagingArea\assets\bin\Data\Managed\Assembly-CSharp-firstpass.dll" --assembly="【Unity プロジェクト】\Temp\StagingArea\assets\bin\Data\Managed\Assembly-CSharp.dll" --assembly="【Unity プロジェクト】\Temp\StagingArea\assets\bin\Data\Managed\Unity.TextMeshPro.dll" --assembly="【Unity プロジェクト】\Temp\StagingArea\assets\bin\Data\Managed\UnityEngine.UI.dll" --assembly="【Unity プロジェクト】\Temp\StagingArea\assets\bin\Data\Managed\DOTween.dll" --assembly="【Unity プロジェクト】\Temp\StagingArea\assets\bin\Data\Managed\UnityEngine.dll" --generatedcppdir="【Unity プロジェクト】\Temp\StagingArea\Il2Cpp\il2cppOutput" 

stdout:
Building libil2cpp.so with AndroidToolChain
    Output directory: 【Unity プロジェクト】\Temp\StagingArea\assets\bin\Data\Native\armeabi-v7a
    Cache directory: 【Unity プロジェクト】\Library\il2cpp_android_armeabi-v7a\il2cpp_cache
il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException: 【Unity プロジェクト】\Temp\StagingArea\Il2Cpp\il2cppOutput\UnityInitializeChecker.cpp:1:10: fatal error: 'mach/mach.h' file not found
#include <mach/mach.h>
         ^
1 error generated.


Invocation was: Executable: "C:\android-ndk-r13b-windows-x86_64\android-ndk-r13b\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++"
Arguments: -DGC_NOT_DLL -DRUNTIME_IL2CPP -DLINUX -DANDROID -DPLATFORM_ANDROID -D__linux__ -D__STDC_FORMAT_MACROS -I"C:\Program Files\Unity 2018.2.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\bdwgc\include" -I"C:\Program Files\Unity 2018.2.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\libil2cpp\include" -I"C:\Program Files\Unity 2018.2.7f1\Editor\Data\il2cpp\libil2cpp" -I"C:\Program Files\Unity 2018.2.7f1\Editor\Data\il2cpp\external\boehmgc\include" -I"【Unity プロジェクト】\Temp\StagingArea\Il2Cpp\il2cppOutput" -I"." -I"C:\android-ndk-r13b-windows-x86_64\android-ndk-r13b\sources\cxx-stl\gnu-libstdc++\4.9\include" -I"C:\android-ndk-r13b-windows-x86_64\android-ndk-r13b\sources\cxx-stl\gnu-libstdc++\4.9\include\backward" -I"C:\android-ndk-r13b-windows-x86_64\android-ndk-r13b\sources\cxx-stl\gnu-libstdc++\4.9\libs\armeabi-v7a\include" -c -g -DNDEBUG -funwind-tables -fno-limit-debug-info -fdata-sections -ffunction-sections -Wa,--noexecstack -fno-rtti -std=c++98 -fno-strict-aliasing -fvisibility=hidden -fvisibility-inlines-hidden -fno-strict-overflow -Os --sysroot "C:\android-ndk-r13b-windows-x86_64\android-ndk-r13b\platforms\android-16\arch-arm" -gcc-toolchain "C:\android-ndk-r13b-windows-x86_64\android-ndk-r13b\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" -target armv7-none-linux-androideabi -march=armv7-a -mfloat-abi=softfp -mfpu=neon -fPIE "【Unity プロジェクト】\Temp\StagingArea\Il2Cpp\il2cppOutput\UnityInitializeChecker.cpp" -o "【Unity プロジェクト】/app/Library/il2cpp_android_armeabi-v7a/il2cpp_cache/C31C228FA9F4596CAF96B73A7D64664E.o"

   �ꏊ Unity.IL2CPP.Building.CppProgramBuilder.BuildAllCppFiles(IEnumerable`1 sourceFilesToCompile, IBuildStatisticsCollector statisticsCollector)
   �ꏊ Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
   �ꏊ il2cpp.Program.DoRun(String[] args)
   �ꏊ il2cpp.Program.Run(String[] args)
   �ꏊ il2cpp.Program.Main(String[] args)
stderr:

�n���h�������Ă��Ȃ����O: Unity.IL2CPP.Building.BuilderFailedException: 【Unity プロジェクト】\Temp\StagingArea\Il2Cpp\il2cppOutput\UnityInitializeChecker.cpp:1:10: fatal error: 'mach/mach.h' file not found
#include <mach/mach.h>
         ^
1 error generated.


Invocation was: Executable: "C:\android-ndk-r13b-windows-x86_64\android-ndk-r13b\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++"
Arguments: -DGC_NOT_DLL -DRUNTIME_IL2CPP -DLINUX -DANDROID -DPLATFORM_ANDROID -D__linux__ -D__STDC_FORMAT_MACROS -I"C:\Program Files\Unity 2018.2.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\bdwgc\include" -I"C:\Program Files\Unity 2018.2.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\libil2cpp\include" -I"C:\Program Files\Unity 2018.2.7f1\Editor\Data\il2cpp\libil2cpp" -I"C:\Program Files\Unity 2018.2.7f1\Editor\Data\il2cpp\external\boehmgc\include" -I"【Unity プロジェクト】\Temp\StagingArea\Il2Cpp\il2cppOutput" -I"." -I"C:\android-ndk-r13b-windows-x86_64\android-ndk-r13b\sources\cxx-stl\gnu-libstdc++\4.9\include" -I"C:\android-ndk-r13b-windows-x86_64\android-ndk-r13b\sources\cxx-stl\gnu-libstdc++\4.9\include\backward" -I"C:\android-ndk-r13b-windows-x86_64\android-ndk-r13b\sources\cxx-stl\gnu-libstdc++\4.9\libs\armeabi-v7a\include" -c -g -DNDEBUG -funwind-tables -fno-limit-debug-info -fdata-sections -ffunction-sections -Wa,--noexecstack -fno-rtti -std=c++98 -fno-strict-aliasing -fvisibility=hidden -fvisibility-inlines-hidden -fno-strict-overflow -Os --sysroot "C:\android-ndk-r13b-windows-x86_64\android-ndk-r13b\platforms\android-16\arch-arm" -gcc-toolchain "C:\android-ndk-r13b-windows-x86_64\android-ndk-r13b\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" -target armv7-none-linux-androideabi -march=armv7-a -mfloat-abi=softfp -mfpu=neon -fPIE "【Unity プロジェクト】\Temp\StagingArea\Il2Cpp\il2cppOutput\UnityInitializeChecker.cpp" -o "【Unity プロジェクト】/app/Library/il2cpp_android_armeabi-v7a/il2cpp_cache/C31C228FA9F4596CAF96B73A7D64664E.o"

   �ꏊ Unity.IL2CPP.Building.CppProgramBuilder.BuildAllCppFiles(IEnumerable`1 sourceFilesToCompile, IBuildStatisticsCollector statisticsCollector)
   �ꏊ Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
   �ꏊ il2cpp.Program.DoRun(String[] args)
   �ꏊ il2cpp.Program.Run(String[] args)
   �ꏊ il2cpp.Program.Main(String[] args)

UnityEngine.Debug:LogError(Object)
UnityEditorInternal.Runner:RunProgram(Program, String, String, String, CompilerOutputParserBase) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:128)
UnityEditorInternal.Runner:RunManagedProgram(String, String, String, CompilerOutputParserBase, Action`1) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:73)
UnityEditorInternal.IL2CPPBuilder:RunIl2CppWithArguments(List`1, Action`1, String) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:380)
UnityEditorInternal.IL2CPPBuilder:ConvertPlayerDlltoCpp(ICollection`1, String, String, Boolean) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:361)
UnityEditorInternal.IL2CPPBuilder:Run() (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:178)
UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, String, IIl2CppPlatformProvider, Action`1, RuntimeClassRegistry) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:35)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
Exception: C:\Program Files\Unity 2018.2.7f1\Editor\Data\il2cpp/build/il2cpp.exe did not run properly!
UnityEditorInternal.Runner.RunProgram (UnityEditor.Utils.Program p, System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:130)
UnityEditorInternal.Runner.RunManagedProgram (System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser, System.Action`1 setupStartInfo) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:73)
UnityEditorInternal.IL2CPPBuilder.RunIl2CppWithArguments (System.Collections.Generic.List`1 arguments, System.Action`1 setupStartInfo, System.String workingDirectory) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:380)
UnityEditorInternal.IL2CPPBuilder.ConvertPlayerDlltoCpp (ICollection`1 userAssemblies, System.String outputDirectory, System.String workingDirectory, Boolean platformSupportsManagedDebugging) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:361)
UnityEditorInternal.IL2CPPBuilder.Run () (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:178)
UnityEditorInternal.IL2CPPUtils.RunIl2Cpp (System.String tempFolder, System.String stagingAreaData, IIl2CppPlatformProvider platformProvider, System.Action`1 modifyOutputBeforeCompile, UnityEditor.RuntimeClassRegistry runtimeClassRegistry) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:35)
UnityEditor.Android.PostProcessor.Tasks.RunIl2Cpp.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties)
UnityEditor.PostprocessBuildPlayer.Postprocess (BuildTargetGroup targetGroup, BuildTarget target, System.String installPath, System.String companyName, System.String productName, Int32 width, Int32 height, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:287)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
Build completed with a result of 'Failed'
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
UnityEditor.BuildPlayerWindow+BuildMethodException: 4 errors
  at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (BuildPlayerOptions options) [0x0021f] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:187 
  at UnityEditor.BuildPlayerWindow.CallBuildMethods (Boolean askForBuildLocation, BuildOptions defaultBuildOptions) [0x0007f] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:94 
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
  • #include <mach/mach.h> の部分でエラーが発生→ソースコードが見つからない?
  • Android NDK は r13b で問題なさそう
  • Mono ビルドは正常に完了する
  • Unity 2017.4.7f1 では正常に Android の IL2CPP ビルドができる
  • Gradle ビルドでも Internal ビルドでも関係ない