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 252 forks source link

Build error with glslang #95

Open Ravbug opened 3 years ago

Ravbug commented 3 years ago

In my CMakeLists.txt:

# bgfx
set(BGFX_BUILD_EXAMPLES OFF)
set(BGFX_INSTALL_EXAMPLES OFF)
set(BGFX_INSTALL OFF)
add_subdirectory("${DEPS_DIR}/bgfx.cmake")

I get the following compilation error on Windows (VS 2019):

bgfx.cmake\bgfx\3rdparty\glslang\SPIRV\GlslangToSpv.cpp(61,10): fatal error C1083: Cannot open include file: 'glslang/build_info.h': No such file or directory
mipek commented 3 years ago

I had the same error on Linux (using GCC). I fixed it by adding the following to the bottom of cmake/3rdparty/glslang.cmake:

target_include_directories( glslang PRIVATE ${BGFX_DIR}/3rdparty )

not sure if this is the correct approach to fix this quirk but it works (for now :)

Ravbug commented 3 years ago

If I do that on Windows, the header error is fixed but it's traded for an undefined symbols error in shaderc:

50>glslang.lib(ShaderLang.obj) : error LNK2019: unresolved external symbol "public: __cdecl glslang::HlslParseContext::HlslParseContext(class glslang::TSymbolTable &,class glslang::TIntermediate &,bool,int,enum EProfile,struct glslang::SpvVersion const &,enum EShLanguage,class TInfoSink &,class std::basic_string<char,struct std::char_traits<char>,class glslang::pool_allocator<char> >,bool,enum EShMessages)" (??0HlslParseContext@glslang@@QEAA@AEAVTSymbolTable@1@AEAVTIntermediate@1@_NHW4EProfile@@AEBUSpvVersion@1@W4EShLanguage@@AEAVTInfoSink@@V?$basic_string@DU?$char_traits@D@std@@V?$pool_allocator@D@glslang@@@std@@2W4EShMessages@@@Z) referenced in function "class glslang::TParseContextBase * __cdecl `anonymous namespace'::CreateParseContext(class glslang::TSymbolTable &,class glslang::TIntermediate &,int,enum EProfile,enum glslang::EShSource,enum EShLanguage,class TInfoSink &,struct glslang::SpvVersion,bool,enum EShMessages,bool,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?CreateParseContext@?A0x5e3bac6d@@YAPEAVTParseContextBase@glslang@@AEAVTSymbolTable@3@AEAVTIntermediate@3@HW4EProfile@@W4EShSource@3@W4EShLanguage@@AEAVTInfoSink@@USpvVersion@3@_NW4EShMessages@@7V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
50>glslang.lib(ShaderLang.obj) : error LNK2019: unresolved external symbol "public: __cdecl glslang::TBuiltInParseablesHlsl::TBuiltInParseablesHlsl(void)" (??0TBuiltInParseablesHlsl@glslang@@QEAA@XZ) referenced in function "class glslang::TBuiltInParseables * __cdecl `anonymous namespace'::CreateBuiltInParseables(class TInfoSink &,enum glslang::EShSource)" (?CreateBuiltInParseables@?A0x5e3bac6d@@YAPEAVTBuiltInParseables@glslang@@AEAVTInfoSink@@W4EShSource@3@@Z)
50>glslang.lib(ShaderLang.obj) : error LNK2019: unresolved external symbol "public: static void __cdecl glslang::HlslScanContext::fillInKeywordMap(void)" (?fillInKeywordMap@HlslScanContext@glslang@@SAXXZ) referenced in function ShInitialize
50>glslang.lib(ShaderLang.obj) : error LNK2019: unresolved external symbol "public: static void __cdecl glslang::HlslScanContext::deleteKeywordMap(void)" (?deleteKeywordMap@HlslScanContext@glslang@@SAXXZ) referenced in function ShFinalize
50>C:\Users\Ravbug\Documents\RavEngine-AirHockey\RavEngine\build\debug\shaderc.exe : fatal error LNK1120: 4 unresolved externals

The modification I made to cmake/3rdparty/glslang.cmake:


target_include_directories( glslang PUBLIC
    ${BGFX_DIR}/3rdparty/spirv-tools/include
    ${BGFX_DIR}/3rdparty/spirv-tools/source
    ${BGFX_DIR}/3rdparty/glslang
    ${BGFX_DIR}/3rdparty/glslang/glslang/Include
    ${BGFX_DIR}/3rdparty/glslang/glslang/Public
        # my modification below:
    PRIVATE
    ${BGFX_DIR}/3rdparty
)
azais-corentin commented 3 years ago

On Windows with MSVC 2019, I had to apply both mipek's patch and also #93 in order to the unresolved external symbol errors.