Hello Guest

Function already has a body: main

  • 2 Replies
  • 104 Views
Function already has a body: main
« on: September 17, 2018, 10:00:50 »
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 :

Code: [Select]
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 :
Code: [Select]
#version 330 core
layout (location = 0) in vec3 aPos;

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

Fragment Shader :
Code: [Select]
#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.

*

Offline KaiHH

  • ***
  • 136
Re: Function already has a body: main
« Reply #1 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.

Re: Function already has a body: main
« Reply #2 on: September 17, 2018, 11:09:05 »
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