5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

UnityからIL2CPPでHoloLens用に出力したプロジェクトをビルドするとエラーが発生することがある

Last updated at Posted at 2023-01-06

UnityとVisual Studioのバージョンによって時々起こる模様

UnityからHoloLens用にUWPで出力する際に起きる問題なのですが、IL2CPPでビルドしたものをVisual Studioでビルドするとエラーになることがあります。
その時に以下のように「error C2039: 'hash_compare'」と出る場合があるようです(実際にでてこまった)。

1>EXEC : error : Unity.IL2CPP.Building.BuilderFailedException: Lump_libil2cpp_vm.cpp
1>D:\WorkSpaces\UnityProjects\SamplePrj\APP\Il2CppOutputProject\IL2CPP\libil2cpp\utils/Il2CppHashMap.h(71): error C2039: 'hash_compare': 'stdext' �̃����o�[�ł͂���܂���
1>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\include\iterator(1426): note: 'stdext' �̐錾���m�F���Ă�������
1>D:\WorkSpaces\UnityProjects\SamplePrj\APP\Il2CppOutputProject\IL2CPP\libil2cpp\utils/Il2CppHashMap.h(71): error C2065: 'hash_compare': ��`����Ă��Ȃ����ʎq�ł��B
1>D:\WorkSpaces\UnityProjects\SamplePrj\APP\Il2CppOutputProject\IL2CPP\libil2cpp\utils/Il2CppHashMap.h(71): error C2275: 'Key': �^�̑���Ɏ����K�v�ł�
1>D:\WorkSpaces\UnityProjects\SamplePrj\APP\Il2CppOutputProject\IL2CPP\libil2cpp\vm\MetadataCache.cpp(37): error C2976: 'Il2CppReaderWriterLockedHashMap': ���� �e���v���[�g �����Ȃ����܂�
1>D:\WorkSpaces\UnityProjects\SamplePrj\APP\Il2CppOutputProject\IL2CPP\libil2cpp\utils/Il2CppHashMap.h(75): note: 'Il2CppReaderWriterLockedHashMap' �̐錾���m�F���Ă�������
1>D:\WorkSpaces\UnityProjects\SamplePrj\APP\Il2CppOutputProject\IL2CPP\libil2cpp\vm\MetadataCache.cpp(37): error C2974: 'Il2CppReaderWriterLockedHashMap': �e���v���[�g ������ 'HashFcn' �ɑ΂��Ė����ł��B�^���K�v�ł�
1>D:\WorkSpaces\UnityProjects\SamplePrj\APP\Il2CppOutputProject\IL2CPP\libil2cpp\utils/Il2CppHashMap.h(75): note: 'Il2CppReaderWriterLockedHashMap' �̐錾���m�F���Ă�������
1>D:\WorkSpaces\UnityProjects\SamplePrj\APP\Il2CppOutputProject\IL2CPP\libil2cpp\vm\MetadataCache.cpp(378): error C2662: 'bool Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>::TryGet(const Il2CppHashMap<Key,T,HashFcn,EqualKey,Alloc>::key_type &,T *)': 'PointerTypeMap' ���� 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc> &' �� 'this' �|�C���^�[��ϊ��ł��܂���B
1>D:\WorkSpaces\UnityProjects\SamplePrj\APP\Il2CppOutputProject\IL2CPP\libil2cpp\vm\MetadataCache.cpp(378): note: ���R: 'PointerTypeMap' ���� 'Il2CppReaderWriterLockedHashMap<Key,T,HashFcn,EqualKey,Alloc>' �ւ͕ϊ��ł��܂���B
1>D:\WorkSpaces\UnityProjects\SamplePrj\APP\Il2CppOutputProject\IL2CPP\libil2cpp\vm\MetadataCache.cpp(378): note: �ϊ��ɂ� 2 �Ԗڂ̃��[�U�[��`�ϊ����Z�q�܂��̓R���X�g���N�^�[���K�v�ł��B

解決策

フォーラムにありました。

以下のファイルの中で[#define SPARSEHASH_HASH HASH_NAMESPACE::hash_compare]という定義の前に[#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS]を書くことで解消できます。

  • [Project名]\APP\Il2CppOutputProject\IL2CPP\external\google\sparsehash\internal\sparseconfig.h
sparseconfig.h
・・・

/* Define to 1 if the system has the type `__uint16'. */
#define HAVE___UINT16  1

/* ******************************* 追加行*********************************** */
#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */

/* The system-provided hash function including the namespace. */
#define SPARSEHASH_HASH  HASH_NAMESPACE::hash_compare

/* The system-provided hash function, in namespace HASH_NAMESPACE. */
#define SPARSEHASH_HASH_NO_NAMESPACE  hash_compare

/*************************/
/* POSIX build platforms */
/*************************/

・・・

もし、ビルド時に同じエラーが出てきて困ったら試してみてください。

5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?