keith2018 / SoftGLRender

Tiny C++ Software Renderer / Rasterizer, and implements OpenGL and Vulkan renderers for comparison
MIT License
994 stars 156 forks source link

Failed to build on MSYS2 MINGW64 #49

Closed ghost closed 1 year ago

ghost commented 1 year ago

On MSYS2 MINGW64, the default generator for CMake is Ninja.

CMake configuration is fine:

$ cmake ..
-- Building for: Ninja
-- The C compiler identification is GNU 13.1.0
-- The CXX compiler identification is GNU 13.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/msys64/mingw64/bin/cc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/msys64/mingw64/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Shared libraries disabled
-- compiling zlib from sources
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - done
-- Looking for fseeko
-- Looking for fseeko - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Build an import-only version of Assimp.
-- Enabled importer formats: OBJ GLTF
-- Disabled importer formats: AMF 3DS AC ASE ASSBIN B3D BVH COLLADA DXF CSM HMP IRRMESH IQM IRR LWO LWS M3D MD2 MD3 MD5 MDC MDL NFF NDO OFF OGRE OPENGEX PLY MS3D COB BLEND IFC XGL FBX Q3D Q3BSP RAW SIB SMD STL TERRAGEN 3D X X3D 3MF MMD
-- Treating all warnings as errors (for assimp library only)
-- No build type selected, default to Debug
-- Found PythonInterp: C:/msys64/mingw64/bin/python3.exe (found suitable version "3.10.12", minimum required is "3")
-- spirv-tools not linked - illegal SPIRV may be generated for HLSL
-- Configuring done (1.9s)
-- Generating done (0.1s)
-- Build files have been written to: C:/msys64/home/Administrator/SoftGLRender/build

But when building with Ninja it failed:

$ ninja
ninja: error: 'third_party/glslang/glslang/libglslang.a', needed by 'C:/msys64/home/Administrator/SoftGLRender/bin/SoftGLRender.exe', missing and no known rule to make it
keith2018 commented 1 year ago

It looks like glslang failed to compile, resulting in libglslang.a not being generated, check if there are any other errors before the link error

ghost commented 1 year ago

It looks like glslang failed to compile, resulting in libglslang.a not being generated, check if there are any other errors before the link error

The error above only happens with Ninja generator. Use MSYS Makefiles generator worked. But glslang still failed to build:

$ make
[  0%] Building CXX object third_party/glslang/OGLCompilersDLL/CMakeFiles/OGLCompiler.dir/InitializeDll.cpp.obj
[  0%] Linking CXX static library libOGLCompilerd.a
[  0%] Built target OGLCompiler
[  0%] Building CXX object third_party/glslang/glslang/CMakeFiles/GenericCodeGen.dir/GenericCodeGen/CodeGen.cpp.obj
[  0%] Building CXX object third_party/glslang/glslang/CMakeFiles/GenericCodeGen.dir/GenericCodeGen/Link.cpp.obj
[  1%] Linking CXX static library libGenericCodeGend.a
[  1%] Built target GenericCodeGen
[  2%] Building CXX object third_party/glslang/glslang/OSDependent/Windows/CMakeFiles/OSDependent.dir/ossource.cpp.obj
[  2%] Linking CXX static library libOSDependentd.a
[  2%] Built target OSDependent
[  2%] Building CXX object third_party/glslang/glslang/CMakeFiles/MachineIndependent.dir/MachineIndependent/glslang_tab.cpp.obj
In file included from MachineIndependent/glslang.y:86:
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:649:18: error: 'uint32_t' does not name a type
  649 |     static const uint32_t LevelFlagBitOffset = 56;
      |                  ^~~~~~~~
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:71:1: note: 'uint32_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
   70 | #include "../Include/InfoSink.h"
  +++ |+#include <cstdint>
   71 |
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:662:22: error: 'uint64_t' does not name a type
  662 |     static constexpr uint64_t uniqueIdMask = (1LL << LevelFlagBitOffset) - 1;
      |                      ^~~~~~~~
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:662:22: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:663:18: error: 'uint32_t' does not name a type
  663 |     static const uint32_t MaxLevelInUniqueID = 127;
      |                  ^~~~~~~~
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:663:18: note: 'uint32_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h: In static member function 'static bool glslang::TSymbolTable::isBuiltInSymbol(long long int)':
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:659:50: error: 'LevelFlagBitOffset' was not declared in this scope
  659 |         int level = static_cast<int>(uniqueId >> LevelFlagBitOffset);
      |                                                  ^~~~~~~~~~~~~~~~~~
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h: In member function 'void glslang::TSymbolTable::amendSymbolIdLevel(glslang::TSymbol&)':
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:735:9: error: 'uint64_t' was not declared in this scope
  735 |         uint64_t level = (uint32_t)currentLevel() > MaxLevelInUniqueID ? MaxLevelInUniqueID : currentLevel();
      |         ^~~~~~~~
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:735:9: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:736:18: error: expected ';' before 'symbolId'
  736 |         uint64_t symbolId = symbol.getUniqueId();
      |                  ^~~~~~~~
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:737:9: error: 'symbolId' was not declared in this scope; did you mean 'symbol'?
  737 |         symbolId &= uniqueIdMask;
      |         ^~~~~~~~
      |         symbol
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:737:21: error: 'uniqueIdMask' was not declared in this scope; did you mean 'uniqueId'?
  737 |         symbolId &= uniqueIdMask;
      |                     ^~~~~~~~~~~~
      |                     uniqueId
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:738:22: error: 'level' was not declared in this scope
  738 |         symbolId |= (level << LevelFlagBitOffset);
      |                      ^~~~~
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:738:31: error: 'LevelFlagBitOffset' was not declared in this scope
  738 |         symbolId |= (level << LevelFlagBitOffset);
      |                               ^~~~~~~~~~~~~~~~~~
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h: In member function 'void glslang::TSymbolTable::updateUniqueIdLevelFlag()':
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:932:9: error: 'uint64_t' was not declared in this scope
  932 |         uint64_t level = (uint32_t)currentLevel() > MaxLevelInUniqueID ? MaxLevelInUniqueID : currentLevel();
      |         ^~~~~~~~
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:932:9: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:933:21: error: 'uniqueIdMask' was not declared in this scope; did you mean 'uniqueId'?
  933 |         uniqueId &= uniqueIdMask;
      |                     ^~~~~~~~~~~~
      |                     uniqueId
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:934:22: error: 'level' was not declared in this scope
  934 |         uniqueId |= (level << LevelFlagBitOffset);
      |                      ^~~~~
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:934:31: error: 'LevelFlagBitOffset' was not declared in this scope
  934 |         uniqueId |= (level << LevelFlagBitOffset);
      |                               ^~~~~~~~~~~~~~~~~~
make[2]: *** [third_party/glslang/glslang/CMakeFiles/MachineIndependent.dir/build.make:76: third_party/glslang/glslang/CMakeFiles/MachineIndependent.dir/MachineIndependent/glslang_tab.cpp.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:375: third_party/glslang/glslang/CMakeFiles/MachineIndependent.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

MSYS2 already has glslang packaged, what about just using it?

https://packages.msys2.org/package/mingw-w64-x86_64-glslang

keith2018 commented 1 year ago

It looks like glslang failed to compile, resulting in libglslang.a not being generated, check if there are any other errors before the link error

The error above only happens with Ninja generator. Use MSYS Makefiles generator worked. But glslang still failed to build:

$ make
[  0%] Building CXX object third_party/glslang/OGLCompilersDLL/CMakeFiles/OGLCompiler.dir/InitializeDll.cpp.obj
[  0%] Linking CXX static library libOGLCompilerd.a
[  0%] Built target OGLCompiler
[  0%] Building CXX object third_party/glslang/glslang/CMakeFiles/GenericCodeGen.dir/GenericCodeGen/CodeGen.cpp.obj
[  0%] Building CXX object third_party/glslang/glslang/CMakeFiles/GenericCodeGen.dir/GenericCodeGen/Link.cpp.obj
[  1%] Linking CXX static library libGenericCodeGend.a
[  1%] Built target GenericCodeGen
[  2%] Building CXX object third_party/glslang/glslang/OSDependent/Windows/CMakeFiles/OSDependent.dir/ossource.cpp.obj
[  2%] Linking CXX static library libOSDependentd.a
[  2%] Built target OSDependent
[  2%] Building CXX object third_party/glslang/glslang/CMakeFiles/MachineIndependent.dir/MachineIndependent/glslang_tab.cpp.obj
In file included from MachineIndependent/glslang.y:86:
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:649:18: error: 'uint32_t' does not name a type
  649 |     static const uint32_t LevelFlagBitOffset = 56;
      |                  ^~~~~~~~
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:71:1: note: 'uint32_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
   70 | #include "../Include/InfoSink.h"
  +++ |+#include <cstdint>
   71 |
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:662:22: error: 'uint64_t' does not name a type
  662 |     static constexpr uint64_t uniqueIdMask = (1LL << LevelFlagBitOffset) - 1;
      |                      ^~~~~~~~
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:662:22: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:663:18: error: 'uint32_t' does not name a type
  663 |     static const uint32_t MaxLevelInUniqueID = 127;
      |                  ^~~~~~~~
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:663:18: note: 'uint32_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h: In static member function 'static bool glslang::TSymbolTable::isBuiltInSymbol(long long int)':
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:659:50: error: 'LevelFlagBitOffset' was not declared in this scope
  659 |         int level = static_cast<int>(uniqueId >> LevelFlagBitOffset);
      |                                                  ^~~~~~~~~~~~~~~~~~
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h: In member function 'void glslang::TSymbolTable::amendSymbolIdLevel(glslang::TSymbol&)':
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:735:9: error: 'uint64_t' was not declared in this scope
  735 |         uint64_t level = (uint32_t)currentLevel() > MaxLevelInUniqueID ? MaxLevelInUniqueID : currentLevel();
      |         ^~~~~~~~
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:735:9: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:736:18: error: expected ';' before 'symbolId'
  736 |         uint64_t symbolId = symbol.getUniqueId();
      |                  ^~~~~~~~
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:737:9: error: 'symbolId' was not declared in this scope; did you mean 'symbol'?
  737 |         symbolId &= uniqueIdMask;
      |         ^~~~~~~~
      |         symbol
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:737:21: error: 'uniqueIdMask' was not declared in this scope; did you mean 'uniqueId'?
  737 |         symbolId &= uniqueIdMask;
      |                     ^~~~~~~~~~~~
      |                     uniqueId
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:738:22: error: 'level' was not declared in this scope
  738 |         symbolId |= (level << LevelFlagBitOffset);
      |                      ^~~~~
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:738:31: error: 'LevelFlagBitOffset' was not declared in this scope
  738 |         symbolId |= (level << LevelFlagBitOffset);
      |                               ^~~~~~~~~~~~~~~~~~
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h: In member function 'void glslang::TSymbolTable::updateUniqueIdLevelFlag()':
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:932:9: error: 'uint64_t' was not declared in this scope
  932 |         uint64_t level = (uint32_t)currentLevel() > MaxLevelInUniqueID ? MaxLevelInUniqueID : currentLevel();
      |         ^~~~~~~~
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:932:9: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:933:21: error: 'uniqueIdMask' was not declared in this scope; did you mean 'uniqueId'?
  933 |         uniqueId &= uniqueIdMask;
      |                     ^~~~~~~~~~~~
      |                     uniqueId
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:934:22: error: 'level' was not declared in this scope
  934 |         uniqueId |= (level << LevelFlagBitOffset);
      |                      ^~~~~
C:/msys64/home/Administrator/SoftGLRender/third_party/glslang/glslang/MachineIndependent/SymbolTable.h:934:31: error: 'LevelFlagBitOffset' was not declared in this scope
  934 |         uniqueId |= (level << LevelFlagBitOffset);
      |                               ^~~~~~~~~~~~~~~~~~
make[2]: *** [third_party/glslang/glslang/CMakeFiles/MachineIndependent.dir/build.make:76: third_party/glslang/glslang/CMakeFiles/MachineIndependent.dir/MachineIndependent/glslang_tab.cpp.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:375: third_party/glslang/glslang/CMakeFiles/MachineIndependent.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

MSYS2 already has glslang packaged, what about just using it?

https://packages.msys2.org/package/mingw-w64-x86_64-glslang

I have upgrade glslang to version 12.2.0, looks like they have fix the stdint issue: https://github.com/KhronosGroup/glslang/commit/1e4955adbcd9b3f5eaf2129e918ca057baed6520 try build on MSYS2 again to see if it works

ghost commented 1 year ago

The Ninja generator still not work (will always give the error I posted on the beginning of this thread). I still have to use the MSYS Makefiles generator with cmake -G "MSYS Makefiles" ...

The latest build error is:

[ 82%] Linking CXX static library ../lib/libassimp.a
[ 82%] Built target assimp
[ 82%] Built target SPIRV
make[2]: *** No rule to make target 'third_party/glslang/glslang/libGenericCodeGen.a', needed by 'C:/msys64/home/Administrator/SoftGLRender/bin/SoftGLRender.exe'.  Stop.
make[1]: *** [CMakeFiles/Makefile2:269: CMakeFiles/SoftGLRender.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
ghost commented 1 year ago

I found the issue. It needs CMAKE_BUILD_TYPE to be specified. Setting CMAKE_BUILD_TYPE then the Ninja generator will also work.