Search Unity

IL2CPP build fails

Discussion in 'Windows' started by gecko, May 17, 2020.

  1. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Trying to build with IL2CPP for the first time, but the build fails near the end of the process. Running Unity 2019.2.20. Would much appreciate any help!

    Failed running C:\Program Files\Unity 2019.2.20\Editor\Data\il2cpp/build/il2cpp.exe --convert-to-cpp --emit-null-checks --enable-array-bounds-check --dotnetprofile="unityaot" --compile-cpp --libil2cpp-static --platform="WindowsDesktop" --architecture="x64" --configuration="Release" --outputpath="C:\Users\Main\Documents\WQGameProject\Temp/StagingArea/Data\Native\GameAssembly.dll" --cachedirectory="C:\Users\Main\Documents\WQGameProject\Assets\..\Library/il2cpp_cache" --incremental-g-c-time-slice=3 --profiler-report --map-file-parser="C:/Program Files/Unity 2019.2.20/Editor/Data/Tools/MapFileParser/MapFileParser.exe" --directory="C:/Users/Main/Documents/WQGameProject/Temp/StagingArea/Data/Managed" --generatedcppdir="C:/Users/Main/Documents/WQGameProject/Temp/StagingArea/Data/il2cppOutput"


    stdout:
    Building GameAssembly.dll with MsvcDesktopToolChain
    Msvc Install Version: 15.0
    Msvc Install SDK Directory: C:\Program Files (x86)\Windows Kits\10
    Msvc Linker Path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX64\x64\link.exe
    Msvc Compiler Path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX64\x64\cl.exe

    Output directory: C:\Users\Main\Documents\WQGameProject\Temp\StagingArea\Data\Native
    Cache directory: C:\Users\Main\Documents\WQGameProject\Library\il2cpp_cache
    ObjectFiles: 484 of which compiled: 484
    Time Compile: 104221 milliseconds Rewired_Core19.cpp
    Time Compile: 12066 milliseconds Unity.TextMeshPro1.cpp
    Time Compile: 10540 milliseconds AssemblyDefinitionScripts3.02.cpp
    Time Compile: 10516 milliseconds Rewired_Core10.cpp
    Time Compile: 10056 milliseconds AssemblyDefinitionRootCSharp1.cpp
    Time Compile: 9740 milliseconds mscorlib7.cpp
    Time Compile: 9421 milliseconds Il2CppInvokerTable.cpp
    Time Compile: 8765 milliseconds Il2CppAttributes.cpp
    Time Compile: 8376 milliseconds Il2CppTypeDefinitions.c
    Time Compile: 8114 milliseconds AssemblyDefinitionRootCSharp11.cpp
    Total compilation time: 221961 milliseconds.
    il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX64\x64\link.exe /out:"C:\Users\Main\Documents\WQGameProject\Library\il2cpp_cache\linkresult_1C0E47DDDD43770A6233DF7329A19136\GameAssembly.dll" /DEBUG /INCREMENTAL:NO /LARGEADDRESSAWARE /NXCOMPAT /DYNAMICBASE /NOLOGO /TLBID:1 /OPT:REF /OPT:ICF /HIGHENTROPYVA /DLL /NODEFAULTLIB:uuid.lib "kernel32.lib" "user32.lib" "advapi32.lib" "ole32.lib" "oleaut32.lib" "Shell32.lib" "Crypt32.lib" "psapi.lib" "version.lib" "MsWSock.lib" "ws2_32.lib" "Iphlpapi.lib" "Dbghelp.lib" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\ucrt\x64" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64" /SUBSYSTEM:WINDOWS @"C:\Users\Main\AppData\Local\Temp\tmpE965.tmp"

    Creating library C:\Users\Main\Documents\WQGameProject\Library\il2cpp_cache\linkresult_1C0E47DDDD43770A6233DF7329A19136\GameAssembly.lib and object C:\Users\Main\Documents\WQGameProject\Library\il2cpp_cache\linkresult_1C0E47DDDD43770A6233DF7329A19136\GameAssembly.exp
    0DB8B4271CA5FC104FCCA93FF455B73F.obj : error LNK2019: unresolved external symbol OpenDocumentInMenu referenced in function PDFReader_OpenDocumentInMenu_m1372A8E6D0B18977D1835DF1B0D8C19E93E7E386
    0DB8B4271CA5FC104FCCA93FF455B73F.obj : error LNK2019: unresolved external symbol OpenDocumentInWebViewLocal referenced in function PDFReader_OpenDocumentInWebViewLocal_m294F0A8E943D9DD2089D3E0F6A7390B6D00F18D2
    0DB8B4271CA5FC104FCCA93FF455B73F.obj : error LNK2019: unresolved external symbol OpenDocumentInWebViewLocalWithCallback referenced in function PDFReader_OpenDocumentInWebViewLocalWithCallback_mCAFF76716C8578127AE787373F00BB0833D14741
    0DB8B4271CA5FC104FCCA93FF455B73F.obj : error LNK2019: unresolved external symbol OpenDocumentInWebViewRemote referenced in function PDFReader_OpenDocumentInWebViewRemote_m627A3F0237291269B34957BD9FCE4AEC8C4B2AE3
    0DB8B4271CA5FC104FCCA93FF455B73F.obj : error LNK2019: unresolved external symbol OpenDocumentInWebViewRemoteWithCallback referenced in function PDFReader_OpenDocumentInWebViewRemoteWithCallback_m4894108A8C7C2B81D45EB15EC7E7EAC504A0A838
    0DB8B4271CA5FC104FCCA93FF455B73F.obj : error LNK2019: unresolved external symbol OpenDocumentCG referenced in function PDFReader_OpenDocumentCG_m93250E80DAAEB96BE7F66DE5B97E1AC9A9516ACA
    0DB8B4271CA5FC104FCCA93FF455B73F.obj : error LNK2019: unresolved external symbol OpenHTML referenced in function PDFReader_OpenHTML_m78DB6979F757B19FF101B45B195DF70F0D980FC8
    C:\Users\Main\Documents\WQGameProject\Library\il2cpp_cache\linkresult_1C0E47DDDD43770A6233DF7329A19136\GameAssembly.dll : fatal error LNK1120: 7 unresolved externals

    at Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles(HashSet`1 objectFiles, CppToolChainContext toolChainContext)
    at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
    at il2cpp.Program.DoRun(String[] args)
    at il2cpp.Program.Run(String[] args)
    at il2cpp.Program.Main(String[] args)
    stderr:

    Unhandled Exception: Unity.IL2CPP.Building.BuilderFailedException: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX64\x64\link.exe /out:"C:\Users\Main\Documents\WQGameProject\Library\il2cpp_cache\linkresult_1C0E47DDDD43770A6233DF7329A19136\GameAssembly.dll" /DEBUG /INCREMENTAL:NO /LARGEADDRESSAWARE /NXCOMPAT /DYNAMICBASE /NOLOGO /TLBID:1 /OPT:REF /OPT:ICF /HIGHENTROPYVA /DLL /NODEFAULTLIB:uuid.lib "kernel32.lib" "user32.lib" "advapi32.lib" "ole32.lib" "oleaut32.lib" "Shell32.lib" "Crypt32.lib" "psapi.lib" "version.lib" "MsWSock.lib" "ws2_32.lib" "Iphlpapi.lib" "Dbghelp.lib" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\ucrt\x64" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64" /SUBSYSTEM:WINDOWS @"C:\Users\Main\AppData\Local\Temp\tmpE965.tmp"

    Creating library C:\Users\Main\Documents\WQGameProject\Library\il2cpp_cache\linkresult_1C0E47DDDD43770A6233DF7329A19136\GameAssembly.lib and object C:\Users\Main\Documents\WQGameProject\Library\il2cpp_cache\linkresult_1C0E47DDDD43770A6233DF7329A19136\GameAssembly.exp
    0DB8B4271CA5FC104FCCA93FF455B73F.obj : error LNK2019: unresolved external symbol OpenDocumentInMenu referenced in function PDFReader_OpenDocumentInMenu_m1372A8E6D0B18977D1835DF1B0D8C19E93E7E386
    0DB8B4271CA5FC104FCCA93FF455B73F.obj : error LNK2019: unresolved external symbol OpenDocumentInWebViewLocal referenced in function PDFReader_OpenDocumentInWebViewLocal_m294F0A8E943D9DD2089D3E0F6A7390B6D00F18D2
    0DB8B4271CA5FC104FCCA93FF455B73F.obj : error LNK2019: unresolved external symbol OpenDocumentInWebViewLocalWithCallback referenced in function PDFReader_OpenDocumentInWebViewLocalWithCallback_mCAFF76716C8578127AE787373F00BB0833D14741
    0DB8B4271CA5FC104FCCA93FF455B73F.obj : error LNK2019: unresolved external symbol OpenDocumentInWebViewRemote referenced in function PDFReader_OpenDocumentInWebViewRemote_m627A3F0237291269B34957BD9FCE4AEC8C4B2AE3
    0DB8B4271CA5FC104FCCA93FF455B73F.obj : error LNK2019: unresolved external symbol OpenDocumentInWebViewRemoteWithCallback referenced in function PDFReader_OpenDocumentInWebViewRemoteWithCallback_m4894108A8C7C2B81D45EB15EC7E7EAC504A0A838
    0DB8B4271CA5FC104FCCA93FF455B73F.obj : error LNK2019: unresolved external symbol OpenDocumentCG referenced in function PDFReader_OpenDocumentCG_m93250E80DAAEB96BE7F66DE5B97E1AC9A9516ACA
    0DB8B4271CA5FC104FCCA93FF455B73F.obj : error LNK2019: unresolved external symbol OpenHTML referenced in function PDFReader_OpenHTML_m78DB6979F757B19FF101B45B195DF70F0D980FC8
    C:\Users\Main\Documents\WQGameProject\Library\il2cpp_cache\linkresult_1C0E47DDDD43770A6233DF7329A19136\GameAssembly.dll : fatal error LNK1120: 7 unresolved externals

    at Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles(HashSet`1 objectFiles, CppToolChainContext toolChainContext)
    at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
    at il2cpp.Program.DoRun(String[] args)
    at il2cpp.Program.Run(String[] args)
    at 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:126)
    UnityEditorInternal.Runner:RunManagedProgram(String, String, String, CompilerOutputParserBase, Action`1) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:71)
    UnityEditorInternal.IL2CPPBuilder:RunIl2CppWithArguments(List`1, Action`1, String) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:507)
    UnityEditorInternal.IL2CPPBuilder:ConvertPlayerDlltoCpp(String, String, String, Boolean) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:488)
    UnityEditorInternal.IL2CPPBuilder:Run() (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:334)
    UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, IIl2CppPlatformProvider, Action`1, RuntimeClassRegistry) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:70)
    DesktopStandalonePostProcessor:SetupStagingArea(BuildPostProcessArgs, HashSet`1) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/DesktopStandalonePostProcessor.cs:243)
    DesktopStandalonePostProcessor:postProcess(BuildPostProcessArgs) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/DesktopStandalonePostProcessor.cs:41)


    _________________________






    Unhandled Exception: Unity.IL2CPP.Building.BuilderFailedException: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX64\x64\link.exe /out:" Library\il2cpp_cache\linkresult_1C0E47DDDD43770A6233DF7329A19136\GameAssembly.dll" /DEBUG /INCREMENTAL:NO /LARGEADDRESSAWARE /NXCOMPAT /DYNAMICBASE /NOLOGO /TLBID:1 /OPT:REF /OPT:ICF /HIGHENTROPYVA /DLL /NODEFAULTLIB:uuid.lib "kernel32.lib" "user32.lib" "advapi32.lib" "ole32.lib" "oleaut32.lib" "Shell32.lib" "Crypt32.lib" "psapi.lib" "version.lib" "MsWSock.lib" "ws2_32.lib" "Iphlpapi.lib" "Dbghelp.lib" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\ucrt\x64" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64" /SUBSYSTEM:WINDOWS
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    This failure occurs because the code in the project has extern methods in C#. Methods marked as extern with a the [Dllimport("__Internal")] attribute must be present in a native library that is linked with the Unity player when building with the IL2CPP scripting backend.

    For example, this in this project one function which causes this issue is named: OpenDocumentInMenu

    You have two options:

    1. Build a native library with all of the methods marked as extern with the [Dllimport("__Internal")] attribute for the target platform and architecture of the player. See this documentation for details about native plugins: https://docs.unity3d.com/Manual/NativePlugins.html

    2. Remove the C# code which defines this extern method. You can do that with platform dependent compilation: https://docs.unity3d.com/Manual/PlatformDependentCompilation.html
     
  3. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Thank you! There was an old asset store plugin in the project, not using it, so deleting that got the build to finish successfully.

    But when I run the build, it stalls out on the initial loading screen. Doesn't crash, doesn't continue from there. The log isn't useful, it just stops recording things (last lines are normal, about terrain shaders in the first scene). Is there any way to debug why this is only happening in the IL2CPP build?
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    You can enable script debugging and debug the managed code as you would with Mono.