Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: ERROR: Not all shaders have valid object code.

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2012
    Location
    Moscow, Darmstadt, Geneve
    Posts
    4

    ERROR: Not all shaders have valid object code.

    Hello, everybody.

    Searched in the net, many posts by no answer.
    Trying to make the easiest programm get this error:
    "Linker failure: Vertex shader(s) failed to link, no fragment shader(s) defined." or
    "Linker failure: Vertex shader(s) failed to link, fragment shader(s) failed to link." depending on the configuration (frag shader off/on.
    "ERROR: Not all shaders have valid object code.ERROR: Not all shaders have valid object code."

    Both shaders do compile succesfully. Debugging shows that glLinkProgram fails.

    Using MSVC++ 2010 under Win7.
    Does anything depend on the harware? My graph card supports only version 3.2. Changing 1st line in shaders to
    #version 320
    does not help.

    Vertex shader:
    -----------------------------------------------------
    #version 420

    layout (location = 0) in vec4 in_Position;
    layout (location = 1) in vec4 in_Color;

    smooth out vec4 ex_Color;

    void main()
    {
    gl_Position = in_Position;
    ex_Color = in_Color;
    }
    -----------------------------------------------------

    Fragment shader:
    -----------------------------------------------------
    #version 420

    smooth in vec4 ex_Color;

    out vec4 out_Color;

    void main()
    {
    out_Color = ex_Color;
    }
    -----------------------------------------------------


    Some parts from the source:

    ...
    GLuint theProg;
    ...
    std::vector<GLuint> shaderList;
    shaderList.push_back(OvchCreateShader(GL_VERTEX_SH ADER, VertShaderFilename));
    shaderList.push_back(OvchCreateShader(GL_FRAGMENT_ SHADER, FragShaderFilename));
    theProg = OvchCreateProg(shaderList);
    std::for_each(shaderList.begin(), shaderList.end(), glDeleteShader);
    ...
    GLuint program = glCreateProgram();
    for (size_t iLoop = 0; iLoop < shaderList.size(); iLoop++)
    { glAttachShader(program, shaderList[iLoop]); }
    glLinkProgram(program);
    ...


    Thank you! Any ideas?


    Solved:
    Stupid mistake - I did not send the shader's source to the glShaderSource inside my OvchCreateShader.

    But now I get another problem.

    ERROR: 0:1: '' : Version number not supported by GL2
    ERROR: 0:3: 'layout' : syntax error parse error
    ERROR: compilation errors. No code generated.

    ERROR: 0:1: '' : Version number not supported by GL2
    ERROR: 0:3: 'layout' : syntax error parse error
    ERROR: compilation errors. No code generated.

    ERROR: 0:1: '' : Version number not supported by GL2
    ERROR: compilation errors. No code generated.

    ERROR: 0:1: '' : Version number not supported by GL2
    ERROR: compilation errors. No code generated.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2009
    Posts
    529

    Re: ERROR: Not all shaders have valid object code.

    Does anything depend on the harware? My graph card supports only version 3.2. Changing 1st line in shaders to
    #version 320
    does not help.
    if your card only support GL 3.2 (which is odd, such a card would also likely support GL3.3, what is the card and driver pair?) then doing #version 420 is a .... recipe.. for bad things to happen.


    Without seeing the contents of OvchCreateShader, it is hard to tell.... my suspicion is a "silent read file error" on the fragment shader and/or vertex shader. An empty string is a valid shader which would compile fine...

    the call: glGetShaderSource will have GL return to you what it thinks the shader source code is...

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2012
    Location
    Moscow, Darmstadt, Geneve
    Posts
    4

    Re: ERROR: Not all shaders have valid object code.

    I have ATI Mobility Radeon HD 4300 Series and corresponding driver. It is a laptop.


    Below is the OvchCreateShader implementation.
    I modified it a little bit since the last post, but still...
    At the end you'll fins the messages during run.
    Code :
    GLuint OvchRenderer::OvchCreateShader(GLenum eShaderType, const string&amp; strShaderFile)
    {
    	GLuint shader = glCreateShader(eShaderType);
     
    	// Read shader from the file with name `strShaderFile` into string `strShaderData`
    	string strShaderData;
    	string line;
    	std::ifstream fileShader (strShaderFile);
    	if (fileShader.is_open())
    	{
    		while (fileShader.good())
    		{
    			getline(fileShader, line);
    			strShaderData += line + "\n";
    		}
    		fileShader.close();
    	}
    	else
    		*debugFile << "Error opening shader file:" << strShaderFile << endl;
     
    	// Convert string `strShaderData` into C-type string `cstrShaderData`
    	char* cstrShaderData;
    	cstrShaderData = new char [strShaderData.size()+1];
    	strcpy_s (cstrShaderData, strShaderData.size()+1, strShaderData.c_str());
     
    	// Debug output
    	*debugFile << "-----------------------" << endl;
    	*debugFile << cstrShaderData;
    	*debugFile << "-----------------------" << endl;
     
    	glShaderSource(shader, 1, (const GLchar**)&amp;cstrShaderData, NULL);
     
    	glCompileShader(shader);
     
    	// Get diagnostics info and print it in case of error
    	GLint status;
    	glGetShaderiv(shader, GL_COMPILE_STATUS, &amp;status);
    	if (status == GL_FALSE)
    	{
    		GLint infoLogLength;
    		glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &amp;infoLogLength);
     
    		GLchar *strInfoLog = new GLchar[infoLogLength + 1];
    		glGetShaderInfoLog(shader, infoLogLength, NULL, strInfoLog);
     
    		const char *strShaderType = NULL;
    		switch(eShaderType)
    		{
    		case GL_VERTEX_SHADER: strShaderType = "vertex"; break;
    		case GL_GEOMETRY_SHADER: strShaderType = "geometry"; break;
    		case GL_FRAGMENT_SHADER: strShaderType = "fragment"; break;
    		}
     
    		*debugFile << "Compile failure in " << strShaderType  << " shader:" << endl << strInfoLog << endl;
    		delete[] strInfoLog;
    	}
     
    	return shader;
    }

    Debug output
    Code :
    -----------------------
    #version 320
     
    layout (location = 0) in vec4 in_Position;
    layout (location = 1) in vec4 in_Color;
     
    smooth out vec4 ex_Color;
     
    void main()
    {
    	gl_Position = in_Position;
    	ex_Color = in_Color;
    }
    -----------------------
    Compile failure in vertex shader:
    Vertex shader failed to compile with the following errors:
    ERROR: 0:1: '' :  Version number not supported by GL2
    ERROR: 0:3: 'layout' : syntax error parse error
    ERROR:  compilation errors.  No code generated.
     
    -----------------------
    #version 320
     
    smooth in vec4 ex_Color;
     
    out vec4 out_Color;
     
    void main()
    {
    	out_Color = ex_Color;
    }
    -----------------------
    Compile failure in fragment shader:
    Fragment shader failed to compile with the following errors:
    ERROR: 0:1: '' :  Version number not supported by GL2
    ERROR:  compilation errors.  No code generated.
     
    Linker failure: Vertex and Fragment shader(s) were not successfully compiled before glLinkProgram() was called.  Link failed.

  4. #4
    Member Regular Contributor
    Join Date
    Apr 2009
    Posts
    258

    Re: ERROR: Not all shaders have valid object code.

    Please note that there is no 320 version for GLSL. GLSL version that was introduced in GL 3.2 is 150.

    Edit: Also, layout declarations for attribute/frag out bindings are available from GLSL 330 on, so you will need to rewrite if you want to target GLSL 150.

  5. #5
    Junior Member Newbie
    Join Date
    Apr 2012
    Location
    Moscow, Darmstadt, Geneve
    Posts
    4

    Re: ERROR: Not all shaders have valid object code.

    So, please, let me formulate the quiestion another way.

    I would like to write my program using OpenGL 4.2 core profile.
    Suppose I have a mashine with the corresponding graph card, but I do not have permanent access to it.
    Can I work somehow on my laptop with that "ATI Mobility Radeon HD 4300 Series"?

    Thank you.

  6. #6
    Junior Member Newbie
    Join Date
    Apr 2012
    Location
    Moscow, Darmstadt, Geneve
    Posts
    4

    Re: ERROR: Not all shaders have valid object code.

    Here is some info concearning the problem

    http://developer.nvidia.com/opengl-driver

    Soon I'll try to do something with NVidia Quadro 600

  7. #7
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421

    Re: ERROR: Not all shaders have valid object code.

    Quote Originally Posted by evovch
    So, please, let me formulate the quiestion another way.

    I would like to write my program using OpenGL 4.2 core profile.
    Suppose I have a mashine with the corresponding graph card, but I do not have permanent access to it.
    Can I work somehow on my laptop with that "ATI Mobility Radeon HD 4300 Series"?

    Thank you.
    I suppose you can write a program that converts your GLSL shader between systems and you should be fine as long as you don't really use GL 4.2 features in your shader and your source code.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •