Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Unity 2022.1.22f1 with IL2CPP not working

Discussion in 'Editor & General Support' started by SniperED007, Nov 10, 2022.

  1. SniperED007

    SniperED007

    Joined:
    Sep 29, 2013
    Posts:
    345
    Trying to do a build on Unity 2022.1.22f1 with IL2CPP enabled.
    Visual Studio Version 17.4.0
    Windows 10.

    Throwing the following errors on build:

    Code (CSharp):
    1. Building Library\Bee\artifacts\WinPlayerBuildProgram\ei6vj\ejx6_b_vm6.lump.obj failed with output:
    2. i3ib_vm6.lump.cpp
    3. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(71): error C2039: 'hash_compare': is not a member of 'stdext'
    4. C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.34.31933\include\iterator(1426): note: see declaration of 'stdext'
    5. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(71): error C2065: 'hash_compare': undeclared identifier
    6. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(71): error C2275: 'Key': expected an expression instead of a type
    7. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(38): error C2976: 'Il2CppReaderWriterLockedHashMap': too few template arguments
    8. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(75): note: see declaration of 'Il2CppReaderWriterLockedHashMap'
    9. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(38): error C2974: 'Il2CppReaderWriterLockedHashMap': invalid template argument for 'HashFcn', type expected
    10. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(75): note: see declaration of 'Il2CppReaderWriterLockedHashMap'
    11. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(38): error C2955: 'Il2CppReaderWriterLockedHashMap': use of class template requires template argument list
    12. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(75): note: see declaration of 'Il2CppReaderWriterLockedHashMap'
    13. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(47): error C2955: 'Il2CppReaderWriterLockedHashMap': use of class template requires template argument list
    14. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(75): note: see declaration of 'Il2CppReaderWriterLockedHashMap'
    15. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(385): error C2662: 'bool Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>::TryGet(const Il2CppHashMap<Key,T,HashFcn,EqualKey,Alloc>::key_type &,T *)': cannot convert 'this' pointer from 'PointerTypeMap' to 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc> &'
    16. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(385): note: Reason: cannot convert from 'PointerTypeMap' to 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>'
    17. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(385): note: Conversion requires a second user-defined-conversion operator or constructor
    18. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(90): note: see declaration of 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>::TryGet'
    19. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(385): note: while trying to match the argument list '(Il2CppClass *, Il2CppClass **)'
    20. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(438): error C2662: 'bool Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>::Add(const Il2CppHashMap<Key,T,HashFcn,EqualKey,Alloc>::key_type &,const T &)': cannot convert 'this' pointer from 'PointerTypeMap' to 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc> &'
    21. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(438): note: Reason: cannot convert from 'PointerTypeMap' to 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>'
    22. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(438): note: Conversion requires a second user-defined-conversion operator or constructor
    23. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(102): note: see declaration of 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>::Add'
    24. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(438): note: while trying to match the argument list '(Il2CppClass *, Il2CppClass *)'
    25. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(1157): error C2955: 'Il2CppReaderWriterLockedHashMap': use of class template requires template argument list
    26. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(75): note: see declaration of 'Il2CppReaderWriterLockedHashMap'
    27. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(1157): error C2662: 'Il2CppHashMap<Key,T,HashFcn,EqualKey,Alloc>::iterator Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>::UnlockedBegin(void)': cannot convert 'this' pointer from 'PointerTypeMap' to 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc> &'
    28. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(1157): note: Reason: cannot convert from 'PointerTypeMap' to 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>'
    29. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(1157): note: Conversion requires a second user-defined-conversion operator or constructor
    30. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(121): note: see declaration of 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>::UnlockedBegin'
    31. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(1157): note: while trying to match the argument list '()'
    32. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(1157): error C2662: 'Il2CppHashMap<Key,T,HashFcn,EqualKey,Alloc>::iterator Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>::UnlockedEnd(void)': cannot convert 'this' pointer from 'PointerTypeMap' to 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc> &'
    33. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(1157): note: Reason: cannot convert from 'PointerTypeMap' to 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>'
    34. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(1157): note: Conversion requires a second user-defined-conversion operator or constructor
    35. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(127): note: see declaration of 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>::UnlockedEnd'
    36. C:\Program Files\Unity\Hub\Editor\2022.1.22f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(1157): note: while trying to match the argument list '()'
    37. UnityEditor.BuildPlayerWindow:BuildPlayerAndRun ()
    38.  
     
    BAIZOR likes this.
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,514
    First, make a blank project with a single blank scene and prove that it builds successfully.

    If it does NOT build, then go fix your Unity installation, or your other tools, such as Android SDK, NDK, JDK, etc.

    Until you can build a blank project to the target platform, don't fiddle with anything else.

    Here was how I brought up Unity2020.3.41 and the Android SDK 31 on October 30, 2022:

    https://forum.unity.com/threads/aab...y-2021-3-8-with-jdk-1-8.1322211/#post-8551193

    Once you can build a blank project, now bisect the problem by bringing over parts of your current project and building it one subsystem at a time, perhaps stubbing things out that might trigger compiler errors.

    Most often things that prevent building are third-party libraries such as Firebase.

    Once you identify the subsystem, go to the documentation for it and make sure you are doing it correctly.

    It may also be helpful to work through a tutorial or two for whatever subsystem is making the build fail.
     
  3. SniperED007

    SniperED007

    Joined:
    Sep 29, 2013
    Posts:
    345
    This is a Windows 10 build.
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,514
    Everything above still stands. The android setup part is simply an example. If you can't build a blank project, why waste time until that works?
     
  5. SniperED007

    SniperED007

    Joined:
    Sep 29, 2013
    Posts:
    345
    This is a brand-new clean project.
     
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,514
    It sounds like perhaps you haven't installed software before. Sometimes a particular version of software will not function, for any number of ten billion different reasons: operating system problems, corrupted files, version incompatibilities, etc.

    The reasons are manifold and irrelevant.

    At the point you have reached, traditionally one would reach for first a complete reinstall of the software. If that does not work, then one would reach for a different version of the software.
     
  7. SniperED007

    SniperED007

    Joined:
    Sep 29, 2013
    Posts:
    345
  8. BAIZOR

    BAIZOR

    Joined:
    Jul 4, 2013
    Posts:
    112
    I have a very similar issue with Unity 2021.3.13. Just I am doing it with my project (not blank I mean). The error logs don't provide helpful information. Can you give me a direction to research?
    • Windows 10.
    • IL2CPP enabled
    • .NET Standard 2.1

    Code (CSharp):
    1. Building Library\Bee\artifacts\WinPlayerBuildProgram\ravy3\gf78_a_vm6.lump.obj failed with output:
    2. ella_vm6.lump.cpp
    3. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(71): error C2039: 'hash_compare': is not a member of 'stdext'
    4. F:\Programs\Visual Studio\Visual Studio 2022\VC\Tools\MSVC\14.34.31933\include\iterator(1426): note: see declaration of 'stdext'
    5. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(71): error C2065: 'hash_compare': undeclared identifier
    6. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(71): error C2275: 'Key': expected an expression instead of a type
    7. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(38): error C2976: 'Il2CppReaderWriterLockedHashMap': too few template arguments
    8. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(75): note: see declaration of 'Il2CppReaderWriterLockedHashMap'
    9. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(38): error C2974: 'Il2CppReaderWriterLockedHashMap': invalid template argument for 'HashFcn', type expected
    10. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(75): note: see declaration of 'Il2CppReaderWriterLockedHashMap'
    11. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(38): error C2955: 'Il2CppReaderWriterLockedHashMap': use of class template requires template argument list
    12. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(75): note: see declaration of 'Il2CppReaderWriterLockedHashMap'
    13. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(47): error C2955: 'Il2CppReaderWriterLockedHashMap': use of class template requires template argument list
    14. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(75): note: see declaration of 'Il2CppReaderWriterLockedHashMap'
    15. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(385): error C2662: 'bool Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>::TryGet(const Il2CppHashMap<Key,T,HashFcn,EqualKey,Alloc>::key_type &,T *)': cannot convert 'this' pointer from 'PointerTypeMap' to 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc> &'
    16. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(385): note: Reason: cannot convert from 'PointerTypeMap' to 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>'
    17. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(385): note: Conversion requires a second user-defined-conversion operator or constructor
    18. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(90): note: see declaration of 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>::TryGet'
    19. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(385): note: while trying to match the argument list '(Il2CppClass *, Il2CppClass **)'
    20. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(438): error C2662: 'bool Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>::Add(const Il2CppHashMap<Key,T,HashFcn,EqualKey,Alloc>::key_type &,const T &)': cannot convert 'this' pointer from 'PointerTypeMap' to 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc> &'
    21. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(438): note: Reason: cannot convert from 'PointerTypeMap' to 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>'
    22. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(438): note: Conversion requires a second user-defined-conversion operator or constructor
    23. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(102): note: see declaration of 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>::Add'
    24. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(438): note: while trying to match the argument list '(Il2CppClass *, Il2CppClass *)'
    25. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(1135): error C2955: 'Il2CppReaderWriterLockedHashMap': use of class template requires template argument list
    26. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(75): note: see declaration of 'Il2CppReaderWriterLockedHashMap'
    27. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(1135): error C2662: 'Il2CppHashMap<Key,T,HashFcn,EqualKey,Alloc>::iterator Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>::UnlockedBegin(void)': cannot convert 'this' pointer from 'PointerTypeMap' to 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc> &'
    28. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(1135): note: Reason: cannot convert from 'PointerTypeMap' to 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>'
    29. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(1135): note: Conversion requires a second user-defined-conversion operator or constructor
    30. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(121): note: see declaration of 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>::UnlockedBegin'
    31. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(1135): note: while trying to match the argument list '()'
    32. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(1135): error C2662: 'Il2CppHashMap<Key,T,HashFcn,EqualKey,Alloc>::iterator Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>::UnlockedEnd(void)': cannot convert 'this' pointer from 'PointerTypeMap' to 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc> &'
    33. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(1135): note: Reason: cannot convert from 'PointerTypeMap' to 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>'
    34. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(1135): note: Conversion requires a second user-defined-conversion operator or constructor
    35. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\utils\Il2CppHashMap.h(127): note: see declaration of 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>::UnlockedEnd'
    36. F:\Programs\Unity\2021.3.13f1\Editor\Data\il2cpp\libil2cpp\vm\MetadataCache.cpp(1135): note: while trying to match the argument list '()'
    37. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
     
  9. SniperED007

    SniperED007

    Joined:
    Sep 29, 2013
    Posts:
    345
    create a script and put it anywhere in your project:

    Code (CSharp):
    1. #if UNITY_EDITOR
    2. using System;
    3. using UnityEditor.Build;
    4. using UnityEditor.Build.Reporting;
    5. public class MsvcStdextWorkaround : IPreprocessBuildWithReport
    6. {
    7.     const string kWorkaroundFlag = "/D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS";
    8.     public int callbackOrder => 0;
    9.     public void OnPreprocessBuild(BuildReport report)
    10.     {
    11.         var clEnv = Environment.GetEnvironmentVariable("_CL_");
    12.         if (string.IsNullOrEmpty(clEnv))
    13.         {
    14.             Environment.SetEnvironmentVariable("_CL_", kWorkaroundFlag);
    15.         }
    16.         else if (!clEnv.Contains(kWorkaroundFlag))
    17.         {
    18.             clEnv += " " + kWorkaroundFlag;
    19.             Environment.SetEnvironmentVariable("_CL_", clEnv);
    20.         }
    21.     }
    22. }
    23. #endif // UNITY_EDITOR
    The fix is included in Unity 2020.3.42f1, 2021.3.14f1, 2022.1.23f1, 2022.2.0b16 and 2023.1.0a19.
     
  10. BAIZOR

    BAIZOR

    Joined:
    Jul 4, 2013
    Posts:
    112
  11. BAIZOR

    BAIZOR

    Joined:
    Jul 4, 2013
    Posts:
    112
    Sounds great! Let me try.
     
  12. BAIZOR

    BAIZOR

    Joined:
    Jul 4, 2013
    Posts:
    112
    It works. Thanks!
     
  13. Nebuch

    Nebuch

    Joined:
    Aug 30, 2013
    Posts:
    9
    Thanks, this is working on 2022.3.11f .