oryol icon indicating copy to clipboard operation
oryol copied to clipboard

Gfx module doesn't compile with MingW compiler when building for D3D11

Open Oldes opened this issue 6 years ago • 5 comments

Current code is using forward-declarations of enumerations, which is not accepted by MingW, although VS is fine with them. This leads to errors like:

oryol\code\Modules/Gfx/private/d3d11/d3d11_decl.h:35:6: error: use of enum 'D3D11_USAGE' without previous declaration
 enum D3D11_USAGE;

Note: so far MingW also requires this flag: -mno-ms-bitfields for compilation of the Gfx module.

Oldes avatar Apr 06 '18 07:04 Oldes

Yeah, I guess these are the bitfields in GfxTypes.h, with the move to sokol_gfx.h those will be gone as well.

Right now the Windows-specific code basically assumes that you're compiling with the Visual Studio compiler. Did you try compiling with clang? I've read that recent versions can directly consume Windows headers, so I guess it's more compatible with Visual Studio's idea of the C++ standard.

floooh avatar Apr 06 '18 07:04 floooh

I tried clang but so far could not found how to fix these errors:

c:\SDKs\LLVM\bin\clang.exe  oryol\code\Modules\Gfx\Gfx.cc -c -mno-ms-bitfields -O3 -DORYOL_WINDOWS -DORYOL_WIN64 -D_CRT_SECURE_NO_WARNINGS -D_MBCS -DGLM_FORCE_RADIANS=1 -DORYOL_D3D11  -o %_%oryol\code\Modules\Gfx\Gfx.cc.o -Ioryol-samples\ -Ioryol\ -Ioryol\
code\ -Ioryol\code\Modules\ -I..\Glm\glm\
In file included from oryol\code\Modules\Gfx\Gfx.cc:5:
In file included from oryol\code\Modules\Gfx/Gfx.h:12:
In file included from oryol\code\Modules\Gfx/GfxTypes.h:11:
In file included from ..\Glm\glm\glm/vec4.hpp:4:
In file included from ..\Glm\glm\glm/detail/setup.hpp:36:
In file included from ..\Glm\glm\glm/detail/../simd/platform.h:373:
In file included from c:\SDKs\LLVM\lib\clang\5.0.1\include\emmintrin.h:27:
In file included from c:\SDKs\LLVM\lib\clang\5.0.1\include\xmmintrin.h:27:
c:\SDKs\LLVM\lib\clang\5.0.1\include\mmintrin.h:81:40: error: cannot initialize a parameter of type '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values) with an rvalue of type '__v2si' (aka 'int')
    return __builtin_ia32_vec_ext_v2si((__v2si)__m, 0);
                                       ^~~~~~~~~~~

Oldes avatar Apr 06 '18 08:04 Oldes

did you try clang-cl? (or the ms compatibility flags for clang). maybe it helps.

kritzikratzi avatar Jun 25 '18 12:06 kritzikratzi

Could I request a change of the name of this issue to show that it's specifically D3D11 that doesn't build, not the Gfx module as a whole?

pixelherodev avatar Sep 17 '18 01:09 pixelherodev

On that note, is there some config I'm missing that can be used to build for MinGW with OpenGL? Also, is there a way to cross-compile for MinGW off of Linux?

pixelherodev avatar Oct 11 '18 07:10 pixelherodev