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_SHADER, 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.

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…

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.


GLuint OvchRenderer::OvchCreateShader(GLenum eShaderType, const string& 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 + "
";
		}
		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**)&cstrShaderData, NULL);

	glCompileShader(shader);

	// Get diagnostics info and print it in case of error
	GLint status;
	glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
	if (status == GL_FALSE)
	{
		GLint infoLogLength;
		glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &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


-----------------------
#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. 

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.

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.

Here is some info concearning the problem

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

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

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.