Search code examples
glslshadervulkan

Compiling vertex shader from vulkan tutorial with glslc gives error: linking multiple files in not supported yet


I am currently trying to learn programming with/for Vulkan based on the (probably known) tutorial found here: https://vulkan-tutorial.com/

I am at the section which describes how to compile shaders (this part: https://vulkan-tutorial.com/en/Drawing_a_triangle/Graphics_pipeline_basics/Shader_modules)

What I am trying to do is basically just compile the given example for a Vertex Shader using the glsl compiler from the VulkanSDK (I am using linux btw.) The code looks like this (the same code as in the tutorial):

#version 450

layout(location = 0) out vec3 fragColor;

vec2 positions[3] = vec2[](
    vec2(0.0, -0.5),
    vec2(0.5, 0.5),
    vec2(-0.5, 0.5)
);

vec3 colors[3] = vec3[](
    vec3(1.0, 0.0, 0.0),
    vec3(0.0, 1.0, 0.0),
    vec3(0.0, 0.0, 1.0)
);

void main() {
    gl_Position = vec4(positions[gl_VertexIndex], 0.0, 1.0);
    fragColor = colors[gl_VertexIndex];
}

when i try to compile with this command:

glslc shader.vert - o vert.spv

I get this error:

glslc: error: linking multiple files is not supported yet. Use -c to compile files individually.

I am a bit confused because I did not changed anything from the tutorial and was expecting it just to work and I am currently did not understand enough to fix the problem by myself.


Solution

  • Use glslc shader.vert -o vert.spv instead of glslc shader.vert - o vert.spv when compiling your shader.