[soveld][building ogre1.9][DX11] Mingw5.3 32 'IID_totype' was not declared

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
Suryavarman
Halfling
Posts: 41
Joined: Wed Dec 30, 2009 5:22 pm
Location: France
x 1
Contact:

[soveld][building ogre1.9][DX11] Mingw5.3 32 'IID_totype' was not declared

Post by Suryavarman »

Hello,

I try to build Ogre 1.9 with Mingw 5.3 (see http://www.mingw.org ) but i have this error:

From : ogre\RenderSystems\Direct3D11\include\OgreD3D11Texture.h line 95

Code: Select all

		template<typename fromtype, typename totype>
		void _queryInterface(fromtype *from, totype **to)
		{
			HRESULT hr = from->QueryInterface(__uuidof(totype), (void **)to);
..\ogre\OgreMain\include\WIN32\OgreMinGWSupport.h|48|error: 'IID_totype' was not declared in this scope|
It seem mingw make the prepocess instruction before to replace the template type.
Last edited by Suryavarman on Tue Oct 24, 2017 7:46 am, edited 2 times in total.

« Let us be firm, pure and faithful; at the end of our labours, there is the greatest glory in the world, that of the humans who have not given in. »
«Soyons fermes, purs et fidèles; au bout de nos peines il y a la plus grande gloire du monde, celle des Hommes qui n'ont pas cédé. »
CDG

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [building ogre1.9] Mingw5.3 32 'IID_totype' was not decl

Post by dark_sylinc »

Go to OgreMain/include/WIN32/OgreMinGWSupport.h you'll see:

Code: Select all

#ifndef __uuidof(Object)
#   define __uuidof(Object) IID_##Object
#endif
Change it to:

Code: Select all

#ifndef __uuidof
#   define __uuidof(Object) IID_##Object
#endif
And see if that fixes it.
User avatar
Suryavarman
Halfling
Posts: 41
Joined: Wed Dec 30, 2009 5:22 pm
Location: France
x 1
Contact:

Re: [building ogre1.9] Mingw5.3 32 'IID_totype' was not decl

Post by Suryavarman »

« Let us be firm, pure and faithful; at the end of our labours, there is the greatest glory in the world, that of the humans who have not given in. »
«Soyons fermes, purs et fidèles; au bout de nos peines il y a la plus grande gloire du monde, celle des Hommes qui n'ont pas cédé. »
CDG

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [building ogre1.9] Mingw5.3 32 'IID_totype' was not decl

Post by dark_sylinc »

Sounds like an error in the compiler. AFAIK mingw 5.3 is rather old. Have you tried a more recent version of mingw? (or better yet mingw-w64?)
User avatar
Suryavarman
Halfling
Posts: 41
Joined: Wed Dec 30, 2009 5:22 pm
Location: France
x 1
Contact:

Re: [building ogre1.9] Mingw5.3 32 'IID_totype' was not decl

Post by Suryavarman »

Hi, I have try with this versions. If you are another mingw distrubtion tell me:).

Mingw 32bits

TDM : http://tdm-gcc.tdragon.net/
TDM 4.8: CMake cannot generate the project because libcloob-isl-3.dll is missing. ( I have try to reinstall the compiler doesn't work)
TDM 5.1 (The last version) : 'IID_totype' was not declared

Official: http://mingw.org/
Mingw 5.3 'IID_totype' was not declared
Mingw 6.3.0.1 CMake cannot generate the project because libmingwex-0.dll is missing.


Mingw w64 : http://mingw-w64.org:
version(gcc?):7.1.0 architecture: x86_x64 thread:win32: … mingw installation failed cannot download the components.

nuwen: https://nuwen.net/mingw.html (The most recent version of mingw.)
version(mingw?) 15.1 : gcc 7.2.0 architecture: x86_x64 :
cc1plus.exe: error: CPU you selected does not support x86-64 instruction set

« Let us be firm, pure and faithful; at the end of our labours, there is the greatest glory in the world, that of the humans who have not given in. »
«Soyons fermes, purs et fidèles; au bout de nos peines il y a la plus grande gloire du monde, celle des Hommes qui n'ont pas cédé. »
CDG

User avatar
Suryavarman
Halfling
Posts: 41
Joined: Wed Dec 30, 2009 5:22 pm
Location: France
x 1
Contact:

Re: [building ogre1.9] Mingw5.3 32 'IID_totype' was not decl

Post by Suryavarman »

I have resolve the error:

Code: Select all

CPU you selected does not support x86-64 instruction set
Here the patch :
https://ogre3d.atlassian.net/browse/OGRE-580

But now it's funny i have to resolve the freeimage building with mingw-nugwen:
x:\mingw_nuwen\x86_64-w64-mingw32\include\windows.h:9:0,
from [...]freeimage-cmake\freeimage\Source\DeprecationManager\DeprecationMgr.cpp:27:
x:\mingw_nuwen\x86_64-w64-mingw32\include\unknwnbase.h: In member function 'HRESULT IUnknown::QueryInterface(Q**)':
x:\mingw_nuwen\x86_64-w64-mingw32\include\unknwnbase.h:74:29: error: '__mingw_uuidof' was not declared in this scope
return QueryInterface(__uuidof(Q), (void **)pp);
^
x:\mingw_nuwen\x86_64-w64-mingw32\include\unknwnbase.h:74:29: note: suggested alternative: '__mingw_wcstof'

x:\mingw_nuwen\x86_64-w64-mingw32\include\_mingw.h

Code: Select all

/* Macros for __uuidof template-based emulation */
#if defined(__cplusplus) && (USE___UUIDOF == 0)

#define __CRT_UUID_DECL(type,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)           \
    extern "C++" {                                                      \
    template<> inline const GUID &__mingw_uuidof<type>() {              \
        static const IID __uuid_inst = {l,w1,w2, {b1,b2,b3,b4,b5,b6,b7,b8}}; \
        return __uuid_inst;                                             \
    }                                                                   \
    template<> inline const GUID &__mingw_uuidof<type*>() {             \
        return __mingw_uuidof<type>();                                  \
    }                                                                   \
    }

#define __uuidof(type) __mingw_uuidof<__typeof(type)>()

#else

#define __CRT_UUID_DECL(type,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)

#endif

« Let us be firm, pure and faithful; at the end of our labours, there is the greatest glory in the world, that of the humans who have not given in. »
«Soyons fermes, purs et fidèles; au bout de nos peines il y a la plus grande gloire du monde, celle des Hommes qui n'ont pas cédé. »
CDG

User avatar
Suryavarman
Halfling
Posts: 41
Joined: Wed Dec 30, 2009 5:22 pm
Location: France
x 1
Contact:

Re: [building ogre1.9] Mingw5.3 32 'IID_totype' was not declared

Post by Suryavarman »

Here a code sample to reproduce the compilation error: 

main.cpp:

Code: Select all

#include <iostream>

using namespace std;

#define M_TEST(type) g_##type

template <typename T>
T test()
{
	return M_TEST(T);
}

class Scalar
{
	public:
		float x;

		Scalar():
		x(0)
		{}

		Scalar(float inX):
		x(inX)
		{}

		virtual ~Scalar()
		{}

		friend std::ostream& operator << (std::ostream &inOStream, const Scalar &inScalar)
		{
			inOStream << inScalar.x;
			return inOStream;
		}
};

Scalar g_Scalar = Scalar(42);

int main()
{
    cout << __MINGW32_VERSION << endl;

    cout << M_TEST(Scalar) << endl; // OK
    cout << test<Scalar>() << endl; // Failed

    return 0;
}
main.cpp: In function 'T test()':
main.cpp:5:22: error: 'g_T' was not declared in this scope

« Let us be firm, pure and faithful; at the end of our labours, there is the greatest glory in the world, that of the humans who have not given in. »
«Soyons fermes, purs et fidèles; au bout de nos peines il y a la plus grande gloire du monde, celle des Hommes qui n'ont pas cédé. »
CDG

User avatar
Suryavarman
Halfling
Posts: 41
Joined: Wed Dec 30, 2009 5:22 pm
Location: France
x 1
Contact:

Re: [building ogre1.9][DX11] Mingw5.3 32 'IID_totype' was not declared

Post by Suryavarman »

[WAIT]**IT DOESN'T WORK**

A solution to solve that can be this one (not so beautiful)

OgreMingzSupport.h:

Code: Select all

#ifndef __mingw__uuidof(Object)
#   define __mingw__uuidof(Object) IID_##Object
#endif

#ifndef M_MINGW_GET_UUID(type)
	#include <basetyps.h>

	template <typename T>
	REFIID __uuidof2()
	{
		return 0;
	}

	#define M_MINGW_GET_UUID(type) \
	REFIID __uuidof2<>() \
	{ \
		return __mingw__uuidof(type); \
	}
#endif
OgreD3D11Texture.h:
call the M_MINGW_GET_UUID macro to define __uuidof() function for each type of _queryinterface calls. There are the type for the texture pointer define in OgreD3D11Texture.h line 83 to 89

Code: Select all

#ifdef __MINGW32__
	M_MINGW_GET_UUID(ID3D11Texture1D)
	M_MINGW_GET_UUID(ID3D11Texture2D)
	M_MINGW_GET_UUID(ID3D11Texture3D)
	M_MINGW_GET_UUID(ID3D11Resource)
#endif
and use them like that:

Code: Select all

#ifdef __MINGW32__
	HRESULT hr = from->QueryInterface(__uuidof2<totype>(), (void **)to);
#else
	HRESULT hr = from->QueryInterface(__uuidof(totype), (void **)to);
#endif

« Let us be firm, pure and faithful; at the end of our labours, there is the greatest glory in the world, that of the humans who have not given in. »
«Soyons fermes, purs et fidèles; au bout de nos peines il y a la plus grande gloire du monde, celle des Hommes qui n'ont pas cédé. »
CDG

User avatar
Suryavarman
Halfling
Posts: 41
Joined: Wed Dec 30, 2009 5:22 pm
Location: France
x 1
Contact:

Re: [building ogre1.9] Mingw5.3 32 'IID_totype' was not declared

Post by Suryavarman »

Here my proposition to fix it. Is not beautiful.

RenderSystems\Direct311\include\OgreD3D11Texture.h
add this code to the line 41:

Code: Select all

#ifdef __MINGW32__
	#define M_BUILD_GETTER(type) \
	template<> \
	const GUID& getuuid(type** inDummy) \
	{ \
		return __uuidof(type); \
	}

	template <typename T>
	const GUID& getuuid(T** inDummy)
	{
		OgreAssert(false, Ogre::String("Undefined UUID : see OgreD3D11Texture.h"));
		return 0;
	}

	M_BUILD_GETTER(ID3D11Texture1D)
	M_BUILD_GETTER(ID3D11Texture2D)
	M_BUILD_GETTER(ID3D11Texture3D)
	M_BUILD_GETTER(ID3D11Resource)

#endif
in the class Ogre::D3D11Texture::_queryInterface temblate function
replace:

Code: Select all

HRESULT hr = from->QueryInterface(__uuidof(totype), (void **)to);
by this one:

Code: Select all

#ifdef __MINGW32__
   HRESULT hr = from->QueryInterface(getuuid(to), (void **)to);
#else
   HRESULT hr = from->QueryInterface(__uuidof(totype), (void **)to);
#endif
But now i have this error : it cannot build mDevice.isError():

Code: Select all

In file included from [...]ogre\RenderSystems\Direct3D11\src\OgreD3D11DepthBuffer.cpp:30:0:
[...]ogre/RenderSystems/Direct3D11/include/OgreD3D11Texture.h: In member function 'void Ogre::D3D11Texture::_queryInterface(fromtype*, totype**)':
[...]ogre/RenderSystems/Direct3D11/include/OgreD3D11Texture.h:127:28: error: invalid use of incomplete type 'class Ogre::D3D11Device'
    if(FAILED(hr) || mDevice.isError())
                            ^

Here a code sample to understand what i have done:
main.cpp

Code: Select all

#include <iostream>

using namespace std;

#define M_GET_UUID(type) IID_##type

class ClassA
{
	public:
		ClassA()
		{}

		virtual ~ClassA()
		{}
};

class ClassB
{
	public:
		ClassB()
		{}

		virtual ~ClassB()
		{}
};

int IID_ClassA = 1,
	IID_ClassB = 2;


#define M_BUILD_GETTER(type) \
template<> \
int getuuid(const type& inDummy) \
{ \
	return M_GET_UUID(type); \
}

template <typename T>
int getuuid(const T& inDummy)
{
	return 0;
}

M_BUILD_GETTER(ClassA)
M_BUILD_GETTER(ClassB)

int main()
{
    cout << __MINGW32_VERSION << endl;

	ClassA aClassA;
	ClassB aClassB;

    cout << getuuid(aClassA) << endl;
    cout << getuuid(aClassB) << endl;

    return 0;
}

« Let us be firm, pure and faithful; at the end of our labours, there is the greatest glory in the world, that of the humans who have not given in. »
«Soyons fermes, purs et fidèles; au bout de nos peines il y a la plus grande gloire du monde, celle des Hommes qui n'ont pas cédé. »
CDG

User avatar
Suryavarman
Halfling
Posts: 41
Joined: Wed Dec 30, 2009 5:22 pm
Location: France
x 1
Contact:

Re: [building ogre1.9] Mingw5.3 32 'IID_totype' was not declared

Post by Suryavarman »

I have fix my problem like that:
I have add the include "OgreD3DDevice.h"
OgreD3D11Texture.h

Code: Select all

#ifdef __MINGW32__
	#include "OgreD3D11Device.h"

	#define M_BUILD_GETTER(type) \
	template<> \
	const GUID& getuuid(type** inDummy) \
	{ \
		return __uuidof(type); \
	}

	template <typename T>
	const GUID& getuuid(T** inDummy)
	{
		OgreAssert(false, Ogre::String("Undefined UUID : see OgreD3D11Texture.h"));
		return 0;
	}

	M_BUILD_GETTER(ID3D11Texture1D)
	M_BUILD_GETTER(ID3D11Texture2D)
	M_BUILD_GETTER(ID3D11Texture3D)
	M_BUILD_GETTER(ID3D11Resource)

#endif
But at the end only staying this error:
OgreD3D11Device.h:55:84: error: 'CreateEventEx' was not declared in this scope
And the answer it's that:
http://forums.ogre3d.org/viewtopic.php?f=2&t=79810

DirectX 11 is not available for MinGW5.2 32

mingw-w64, MinGW_nuwen versions with the synchapi.h file have it.

« Let us be firm, pure and faithful; at the end of our labours, there is the greatest glory in the world, that of the humans who have not given in. »
«Soyons fermes, purs et fidèles; au bout de nos peines il y a la plus grande gloire du monde, celle des Hommes qui n'ont pas cédé. »
CDG

Post Reply