Function already has a body: main

Started by Pito, September 17, 2018, 10:00:50

Previous topic - Next topic

Pito

Hi guys
I have a small problem :smiley:
"Vertex shader(s) failed to link.
Vertex link error: INVALID_OPERATION.
ERROR: 0:4: error(#248) Function already has a body: main
ERROR: error(#273) 1 compilation errors.  No code generated"

I am trying to do what I learn in cpp into Java using LWJGL ( OpenGL wrapper) But After checking 10000 times I see no reasons why it wouldn't work, giving me this errors :

Vertex shader(s) failed to link.
Vertex link error: INVALID_OPERATION.
ERROR: 0:4: error(#248) Function already has a body: main
ERROR: error(#273) 1 compilation errors.  No code generated


The thing is
my shaders are pretty simple.

Vertex Shader :
#version 330 core
layout (location = 0) in vec3 aPos;

void main()
{
    gl_Position = vec4(aPos, 1.0);
}


Fragment Shader :
#version 330 core
out vec4 FragColor;

void main()
{
    FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f);
}


No syntax error either
The source in the linking is correct too
someone has an idea? It's like they say I shouldn't have 2 Main with those 2 shaders lol

Thank you for your help.

KaiHH

You likely created both shader objects with glCreateShader using GL_VERTEX_SHADER. You have to create the fragment shader using glCreateShader(GL_FRAGMENT_SHADER). Otherwise the linker will assume that both vertex shader objects need to be linked together to form the vertex shader stage.

Pito

Quote from: KaiHH on September 17, 2018, 10:16:36
You likely created both shader objects with glCreateShader using GL_VERTEX_SHADER. You have to create the fragment shader using glCreateShader(GL_FRAGMENT_SHADER). Otherwise the linker will assume that both vertex shader objects need to be linked together to form the vertex shader stage.

omg ... I am so stupid xD thanks a lot