Bart Verberne Bart Verberne - 1 year ago 129
C++ Question

How to use glslang

I am trying to use glslang to compile glsl shader code to SPIR-V binaries.
The glslang project can be found here:

It works well via the glslangValidator.exe manually in the command line.
But i would like to use the c++ interface.

I have build the project as described on the github page, and now I am struggling with how to actually use the interface.

I would rather not actually include any projects in my solution (I am using Visual Studio), but link the .lib's and headers needed to use it.
I just cannot find out which ones i need to link. The github page only mentions ShaderLang.h and StandAlone.cpp, which is not enough.

Can someone explain how to setup a project where you can use glslang? I need it only for compiling glsl shader code to SPIR-V binaries (with debugging info about the shader compilation).
I Suppose this would be a very easy question for someone who has already done it, or has more experience.

Answer Source

There are several libs you need to use. An example consumer to look at is LunarGLASS: There, you can see the file:

Which inside contains this for the libraries:

set(GLSLANGLIBS glslang HLSL OSDependent OGLCompiler SPIRV)

The readme for glslang contains some important information. In addition, within glslang, the glslangValidator tool (basically StandAlone.cpp) shows how to use the API for the libraries. You can also see the Frontends/glslang directory in the LunarGLASS project for a similar use.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download