widberg / bgfx.cmake

https://github.com/bkaradzic/bgfx.cmake. Independently maintained CMake build scripts for bgfx. Released under public domain.
https://github.com/bkaradzic/bgfx.cmake
Creative Commons Zero v1.0 Universal
286 stars 256 forks source link

Windows compile error #13

Closed raulsmartin closed 4 years ago

raulsmartin commented 7 years ago

I've got an error when I was trying to compile bgfx in Windows. This is the following error:

C:\Users\rauls\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\172.3544.40\bin\cmake\bin\cmake.exe --build C:\Users\rauls\CLionProjects\Litecraft\cmake-build-debug --target litecraft -- -j 2
[  6%] Built target pvrtc
[ 20%] Built target bx
[ 26%] Built target squish
[ 33%] Built target edtaa3
[ 33%] Built target etc1
[ 33%] Built target Boost_system
[ 40%] Built target iqa
[ 53%] Built target nvtt
[ 53%] Built target etc2
[ 53%] Built target ib-compress
[ 53%] Built target ocornut-imgui
[ 53%] Built target bimg
[ 60%] Built target Boost_filesystem
[ 60%] Building CXX object bgfx/CMakeFiles/bgfx.dir/bgfx/src/renderer_d3d11.cpp.obj
[ 60%] Building CXX object bgfx/CMakeFiles/bgfx.dir/bgfx/src/renderer_d3d12.cpp.obj
In file included from C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.h:15:0,
                 from C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp:9:
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:946:56: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_COMMAND_QUEUE_FLAGS );
                                                        ^
In file included from C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.h:15:0,
                 from C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp:9:
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:1598:57: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_PIPELINE_STATE_FLAGS );
                                                         ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:1653:65: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_SHADER_MIN_PRECISION_SUPPORT );
                                                                 ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:1715:52: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_FORMAT_SUPPORT1 );
                                                    ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:1733:52: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_FORMAT_SUPPORT2 );
                                                    ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:1741:68: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS );
                                                                    ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:1876:47: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_HEAP_FLAGS );
                                               ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:1916:51: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_RESOURCE_FLAGS );
                                                   ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:2016:55: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_TILE_MAPPING_FLAGS );
                                                       ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:2026:52: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_TILE_COPY_FLAGS );
                                                    ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:2050:52: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_RESOURCE_STATES );
                                                    ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:2087:59: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_RESOURCE_BARRIER_FLAGS );
                                                           ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:2161:53: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_BUFFER_SRV_FLAGS );
                                                     ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:2414:53: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_BUFFER_UAV_FLAGS );
                                                     ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:2608:46: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_DSV_FLAGS );
                                              ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:2644:48: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_CLEAR_FLAGS );
                                                ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:2653:48: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_FENCE_FLAGS );
                                                ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:2671:58: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_DESCRIPTOR_HEAP_FLAGS );
                                                          ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:2763:57: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_ROOT_SIGNATURE_FLAGS );
                                                         ^
In file included from C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12.h:6189:0,
                 from C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.h:15,
                 from C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp:9:
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12sdklayers.h:187:50: error: expected constructor, destructor, or type conversion before ';' token
 DEFINE_ENUM_FLAG_OPERATORS( D3D12_DEBUG_FEATURE );
                                                  ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d12sdklayers.h:200:1: error: expected constructor, destructor, or type conversion before 'extern'
 extern RPC_IF_HANDLE __MIDL_itf_d3d12sdklayers_0000_0001_v0_0_c_ifspec;
 ^~~~~~
In file included from C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.h:37:0,
                 from C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp:9:
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3dx12.h: In function 'UINT64 GetRequiredIntermediateSize(ID3D12Resource*, UINT, UINT)':
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3dx12.h:1359:58: error: expected primary-expression before ')' token
     pDestinationResource->GetDevice(__uuidof(ID3D12Device), reinterpret_cast<void**>(&pDevice));
                                                          ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3dx12.h:1359:58: error: '__uuidof' was not declared in this scope
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3dx12.h: In function 'UINT64 UpdateSubresources(ID3D12GraphicsCommandList*, ID3D12Resource*, ID3D12Resource*, UINT64, UINT, UINT, D3D12_SUBRESOURCE_DATA*)':
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3dx12.h:1453:58: error: expected primary-expression before ')' token
     pDestinationResource->GetDevice(__uuidof(ID3D12Device), reinterpret_cast<void**>(&pDevice));
                                                          ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3dx12.h:1453:58: error: '__uuidof' was not declared in this scope
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3dx12.h: In function 'UINT64 UpdateSubresources(ID3D12GraphicsCommandList*, ID3D12Resource*, ID3D12Resource*, UINT64, UINT, UINT, D3D12_SUBRESOURCE_DATA*)':
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3dx12.h:1481:54: error: there are no arguments to '__uuidof' that depend on a template parameter, so a declaration of '__uuidof' must be available [-fpermissive]
     pDestinationResource->GetDevice(__uuidof(*pDevice), reinterpret_cast<void**>(&pDevice));
                                                      ^
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3dx12.h:1481:54: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
In file included from C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d11.h:14382:0,
                 from C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d11_1.h:127,
                 from C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d11_2.h:66,
                 from C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d11_3.h:115,
                 from C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d11.h:23,
                 from C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d11.cpp:9:
C:/Users/rauls/CLionProjects/Litecraft/bgfx/bgfx/3rdparty/dxsdk/include/d3d11sdklayers.h:129:1: error: expected constructor, destructor, or type conversion before 'extern'
 extern RPC_IF_HANDLE __MIDL_itf_d3d11sdklayers_0000_0000_v0_0_c_ifspec;
 ^~~~~~
C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp: In member function 'void bgfx::d3d12::TextureD3D12::create(const bgfx::Memory*, uint32_t, uint8_t)':
C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp:4213:27: error: invalid conversion from 'int' to 'D3D12_RESOURCE_FLAGS' [-fpermissive]
     resourceDesc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL;
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp:4214:27: error: invalid conversion from 'int' to 'D3D12_RESOURCE_STATES' [-fpermissive]
     state              |= D3D12_RESOURCE_STATE_DEPTH_WRITE;
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp:4215:28: error: invalid conversion from 'int' to 'D3D12_RESOURCE_STATES' [-fpermissive]
     state              &= ~D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp:4231:27: error: invalid conversion from 'int' to 'D3D12_RESOURCE_FLAGS' [-fpermissive]
     resourceDesc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp:4236:27: error: invalid conversion from 'int' to 'D3D12_RESOURCE_FLAGS' [-fpermissive]
     resourceDesc.Flags |= D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE;
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp:4237:28: error: invalid conversion from 'int' to 'D3D12_RESOURCE_STATES' [-fpermissive]
     state              &= ~D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\rauls\CLionProjects\Litecraft\bgfx\bgfx\src\renderer_d3d12.cpp:4242:27: error: invalid conversion from 'int' to 'D3D12_RESOURCE_FLAGS' [-fpermissive]
     resourceDesc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mingw32-make.exe[3]: *** [bgfx/CMakeFiles/bgfx.dir/bgfx/src/renderer_d3d12.cpp.obj] Error 1
bgfx\CMakeFiles\bgfx.dir\build.make:262: recipe for target 'bgfx/CMakeFiles/bgfx.dir/bgfx/src/renderer_d3d12.cpp.obj' failed
mingw32-make.exe[3]: *** Waiting for unfinished jobs....
mingw32-make.exe[3]: *** [bgfx/CMakeFiles/bgfx.dir/bgfx/src/renderer_d3d11.cpp.obj] Error 1
bgfx\CMakeFiles\bgfx.dir\build.make:237: recipe for target 'bgfx/CMakeFiles/bgfx.dir/bgfx/src/renderer_d3d11.cpp.obj' failed
mingw32-make.exe[2]: *** [bgfx/CMakeFiles/bgfx.dir/all] Error 2
CMakeFiles\Makefile2:1073: recipe for target 'bgfx/CMakeFiles/bgfx.dir/all' failed
CMakeFiles\Makefile2:3628: recipe for target 'src/CMakeFiles/litecraft.dir/rule' failed
mingw32-make.exe[1]: *** [src/CMakeFiles/litecraft.dir/rule] Error 2
Makefile:1268: recipe for target 'litecraft' failed
mingw32-make.exe: *** [litecraft] Error 2

I tried also to compile it with the examples, but the same error occur.

JoshuaBrookover commented 7 years ago

What compiler are you using? It's possible I'm missing some define for another compiler. I only test with VS2015 on Windows.

I can also add an option to avoid compiling d3d12 altogether. It's not even fully supported by bgfx yet. Should fix this error for you.

raulsmartin commented 7 years ago

I'm using gcc installed with MinGW Installer. I'm trying to compile with it because I use CLion instead of VS.

JoshuaBrookover commented 7 years ago

That's fine. A few other people have managed to get MinGW working. Can you link me to the specific MinGW installer? There's a couple different ones.

zulis commented 6 years ago

Works fine on Windows with CLion & mingw-w64.

ghost commented 6 years ago

Hello, I am using mingw64 on windows 10, I get the following error:

 error: 'UINT64_C' was not declared in this scope

Full stack trace:

Scanning dependencies of target squish
[  4%] Building CXX object CMakeFiles/ib-compress.dir/bgfx/3rdparty/ib-compress/indexbuffercompression.cpp.obj
[  4%] Building CXX object CMakeFiles/pvrtc.dir/bimg/3rdparty/pvrtc/BitScale.cpp.obj
[  4%] Building C object CMakeFiles/iqa.dir/bimg/3rdparty/iqa/source/convolve.c.obj
[  4%] Building CXX object CMakeFiles/squish.dir/bimg/3rdparty/libsquish/alpha.cpp.obj
In file included from D:\db\bayesian-ai\Dropbox\Tech\cpp\bgfx.cmake\bgfx\3rdparty\ib-compress\indexbuffercompression.h:30:0,
                 from D:\db\bayesian-ai\Dropbox\Tech\cpp\bgfx.cmake\bgfx\3rdparty\ib-compress\indexbuffercompression.cpp:25:
D:\db\bayesian-ai\Dropbox\Tech\cpp\bgfx.cmake\bgfx\3rdparty\ib-compress\writebitstream.h: In member function 'void WriteBitstream::Write(uint32_t, uint32_t)':
D:\db\bayesian-ai\Dropbox\Tech\cpp\bgfx.cmake\bgfx\3rdparty\ib-compress\writebitstream.h:99:131: error: 'UINT64_C' was not declared in this scope
     m_bitBuffer |= ( static_cast<uint64_t>( value ) << ( 64 - m_bitsLeft ) ) & ( m_bitsLeft == 0 ? 0 : UINT64_C(0xFFFFFFFFFFFFFFFF) );
                                                                                                                                   ^
CMakeFiles\ib-compress.dir\build.make:62: recipe for target 'CMakeFiles/ib-compress.dir/bgfx/3rdparty/ib-compress/indexbuffercompression.cpp.obj' failed

When using cygwin:

[  8%] Building CXX object CMakeFiles/bx.dir/bx/src/crtnone.cpp.o
[  8%] Building CXX object CMakeFiles/pvrtc.dir/bimg/3rdparty/pvrtc/PvrTcDecoder.cpp.o
[  8%] Building C object CMakeFiles/iqa.dir/bimg/3rdparty/iqa/source/ssim.c.o
[ 13%] Building CXX object CMakeFiles/squish.dir/bimg/3rdparty/libsquish/colourblock.cpp.o
/cygdrive/d/db/bayesian-ai/Dropbox/Tech/cpp/bgfx.cmake/bx/src/crtnone.cpp:15:10: fatal error: crt0.h: No such file or directory
 #include "crt0.h"
          ^~~~~~~~
compilation terminated.
make[3]: *** [CMakeFiles/bx.dir/build.make:135: CMakeFiles/bx.dir/bx/src/crtnone.cpp.o] Error 1
[ 13%] Building CXX object CMakeFiles/pvrtc.dir/bimg/3rdparty/pvrtc/PvrTcEncoder.cpp.o
make[2]: *** [CMakeFiles/Makefile2:1134: CMakeFiles/bx.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....

And when using vc12:

Scanning dependencies of target bx
[  4%] Building CXX object CMakeFiles/bx.dir/bx/src/allocator.cpp.obj
allocator.cpp
d:\db\bayesian-ai\dropbox\tech\cpp\bgfx.cmake\bx\include\bx\bx.h(35) : error C2144: syntax error : 'bool' should be preceded by ';'
d:\db\bayesian-ai\dropbox\tech\cpp\bgfx.cmake\bx\include\bx\bx.h(46) : error C2146: syntax error : missing ';' before identifier 'Ty'
d:\db\bayesian-ai\dropbox\tech\cpp\bgfx.cmake\bx\include\bx\bx.h(46) : error C2146: syntax error : missing ';' before identifier 'min'
d:\db\bayesian-ai\dropbox\tech\cpp\bgfx.cmake\bx\include\bx\bx.h(46) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\db\bayesian-ai\dropbox\tech\cpp\bgfx.cmake\bx\include\bx\bx.h(46) : error C2143: syntax error : missing ',' before '&'
NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~2.0\VC\bin\cl.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe"' : return code '0x2'

Any help would be appreciated