Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some problems when ADD_SUBDIRECTORYing slang on Windows #5871

Open
James2022-rgb opened this issue Dec 14, 2024 · 2 comments
Open

Some problems when ADD_SUBDIRECTORYing slang on Windows #5871

James2022-rgb opened this issue Dec 14, 2024 · 2 comments
Assignees
Labels
goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang

Comments

@James2022-rgb
Copy link
Contributor

When ADD_SUBDIRECTORYing slang on Windows, building fails with slang-glslang trying to link SPIRV(d).lib:
(sorry, not English)

40>ターゲット Link:
40>  LINK : fatal error LNK1104: ファイル '..\..\external\glslang\SPIRV\Debug\SPIRVd.lib' を開くことができません。

This is because the import library SPIRV(d).lib is not generated alongside the DLL,
which is worked around by setting CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS to ON before the ADD_SUBDIRECTORY:

# So `SPIRV(d).lib` is generated (needed by `slang-glslang`)
SET(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

ADD_SUBDIRECTORY(${MY_SLANG_SRC_DIR} slang)

But next time, linking for slang-glslang fails trying link to methods defined in MachineIndependent:

2>  slang-glslang.obj : error LNK2019: 未解決の外部シンボル "__declspec(dllimport) bool __cdecl glslang::InitializeProcess(void)" (__imp_?InitializeProcess@glslang@@YA_NXZ) が関数 "public: bool __cdecl ProcessInitializer::init(void)" (?init@ProcessInitializer@@QEAA_NXZ) で参照されました
2>  slang-glslang.obj : error LNK2019: 未解決の外部シンボル "__declspec(dllimport) void __cdecl glslang::FinalizeProcess(void)" (__imp_?FinalizeProcess@glslang@@YAXXZ) が関数 "public: __cdecl ProcessInitializer::~ProcessInitializer(void)" (??1ProcessInitializer@@QEAA@XZ) で参照されました
2>  slang-glslang.obj : error LNK2019: 未解決の外部シンボル "__declspec(dllimport) public: __cdecl glslang::TShader::TShader(enum EShLanguage)" (__imp_??0TShader@glslang@@QEAA@W4EShLanguage@@@Z) が関数 "int __cdecl glslang_compileGLSLToSPIRV(struct glslang_CompileRequest_1_2)" (?glslang_compileGLSLToSPIRV@@YAHUglslang_CompileRequest_1_2@@@Z) で参照されました
2>  slang-glslang.obj : error LNK2019: 未解決の外部シンボル "__declspec(dllimport) public: void __cdecl glslang::TShader::setStringsWithLengthsAndNames(char const * const *,int const *,char const * const *,int)" (__imp_?setStringsWithLengthsAndNames@TShader@glslang@@QEAAXPEBQEBDPEBH0H@Z) が関数 "int __cdecl glslang_compileGLSLToSPIRV(struct glslang_CompileRequest_1_2)" (?glslang_compileGLSLToSPIRV@@YAHUglslang_CompileRequest_1_2@@@Z) で参照されました
2>  slang-glslang.obj : error LNK2019: 未解決の外部シンボル "__declspec(dllimport) public: void __cdecl glslang::TShader::setEntryPoint(char const *)" (__imp_?setEntryPoint@TShader@glslang@@QEAAXPEBD@Z) が関数 "int __cdecl glslang_compileGLSLToSPIRV(struct glslang_CompileRequest_1_2)" (?glslang_compileGLSLToSPIRV@@YAHUglslang_CompileRequest_1_2@@@Z) で参照されました
2>  slang-glslang.obj : error LNK2019: 未解決の外部シンボル "__declspec(dllimport) public: void __cdecl glslang::TShader::setDebugInfo(bool)" (__imp_?setDebugInfo@TShader@glslang@@QEAAX_N@Z) が関数 "int __cdecl glslang_compileGLSLToSPIRV(struct glslang_CompileRequest_1_2)" (?glslang_compileGLSLToSPIRV@@YAHUglslang_CompileRequest_1_2@@@Z) で参照されました
2>  slang-glslang.obj : error LNK2019: 未解決の外部シンボル "__declspec(dllimport) public: bool __cdecl glslang::TShader::parse(struct TBuiltInResource const *,int,enum EProfile,bool,bool,enum EShMessages,class glslang::TShader::Includer &)" (__imp_?parse@TShader@glslang@@QEAA_NPEBUTBuiltInResource@@HW4EProfile@@_N2W4EShMessages@@AEAVIncluder@12@@Z) が関数 "public: bool __cdecl glslang::TShader::parse(struct TBuiltInResource const *,int,enum EProfile,bool,bool,enum EShMessages)" (?parse@TShader@glslang@@QEAA_NPEBUTBuiltInResource@@HW4EProfile@@_N2W4EShMessages@@@Z) で参照されました
2>  slang-glslang.obj : error LNK2019: 未解決の外部シンボル "__declspec(dllimport) public: char const * __cdecl glslang::TShader::getInfoLog(void)" (__imp_?getInfoLog@TShader@glslang@@QEAAPEBDXZ) が関数 "int __cdecl glslang_compileGLSLToSPIRV(struct glslang_CompileRequest_1_2)" (?glslang_compileGLSLToSPIRV@@YAHUglslang_CompileRequest_1_2@@@Z) で参照されました
2>  slang-glslang.obj : error LNK2019: 未解決の外部シンボル "__declspec(dllimport) public: __cdecl glslang::TProgram::TProgram(void)" (__imp_??0TProgram@glslang@@QEAA@XZ) が関数 "int __cdecl glslang_compileGLSLToSPIRV(struct glslang_CompileRequest_1_2)" (?glslang_compileGLSLToSPIRV@@YAHUglslang_CompileRequest_1_2@@@Z) で参照されました
2>  slang-glslang.obj : error LNK2019: 未解決の外部シンボル "__declspec(dllimport) public: bool __cdecl glslang::TProgram::link(enum EShMessages)" (__imp_?link@TProgram@glslang@@QEAA_NW4EShMessages@@@Z) が関数 "int __cdecl glslang_compileGLSLToSPIRV(struct glslang_CompileRequest_1_2)" (?glslang_compileGLSLToSPIRV@@YAHUglslang_CompileRequest_1_2@@@Z) で参照されました
2>  slang-glslang.obj : error LNK2019: 未解決の外部シンボル "__declspec(dllimport) public: char const * __cdecl glslang::TProgram::getInfoLog(void)" (__imp_?getInfoLog@TProgram@glslang@@QEAAPEBDXZ) が関数 "int __cdecl glslang_compileGLSLToSPIRV(struct glslang_CompileRequest_1_2)" (?glslang_compileGLSLToSPIRV@@YAHUglslang_CompileRequest_1_2@@@Z) で参照されました
2>  slang-glslang.obj : error LNK2019: 未解決の外部シンボル "__declspec(dllimport) public: bool __cdecl glslang::TProgram::mapIO(class glslang::TIoMapResolver *,class glslang::TIoMapper *)" (__imp_?mapIO@TProgram@glslang@@QEAA_NPEAVTIoMapResolver@2@PEAVTIoMapper@2@@Z) が関数 "int __cdecl glslang_compileGLSLToSPIRV(struct glslang_CompileRequest_1_2)" (?glslang_compileGLSLToSPIRV@@YAHUglslang_CompileRequest_1_2@@@Z) で参照されました

This is because glslang(d).dll does not export the methods defined in the static lib MachineIndependent.lib,
which is worked around by making MachineIndependent use __declspec(dllexport) for GLSLANG_EXPORT:

ADD_SUBDIRECTORY(${MY_SLANG_SRC_DIR} slang)

# So `MachineIndependent` exports methods through `glslang(d).dll`
TARGET_COMPILE_DEFINITIONS(MachineIndependent PRIVATE "GLSLANG_IS_SHARED_LIBRARY=1" "GLSLANG_EXPORTING=1")
@bmillsNV bmillsNV added the goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang label Dec 16, 2024
@bmillsNV bmillsNV added this to the Q4 2024 (Fall) milestone Dec 16, 2024
@James2022-rgb
Copy link
Contributor Author

Also: I had to manually place the miniz.dll alongside slang-bootstrap.exe for the EXE to work.

@jjiangweilan
Copy link

you can try using 'add_dependencies(slang slang-glslang)' in CMake to workaround this without manual placement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang
Projects
None yet
Development

No branches or pull requests

4 participants