OpenGL: What may be the cause of the error "ERROR::SHADER::PROGRAM::LINKING_FAILED"?
<p>Finally I found that it's <strong>the issue of relative file path</strong>.
The fragment code file and the vertex code file are not found with my relative file path. So no code was sent to the shader.
I changed relative file path with absolute path, the project worked well.</p>

<p>--------------------------------Following are more details about my project---------------------------------------</p>

<ul>
<li><p>Xcode version: 6.1 (6A1052c)</p></li>
<li><p>iOS version: OS X E Capitan 10.11.6 (15G31)</p></li>
<li><p>GFX card: Intel Iris 1536 MB</p></li>
<li><p>Code of vertex shader:</p>

<pre><code>#version 330 core
layout (location = 0) in vec3 position;
layout (location = 1) in vec3 color;
layout (location = 2) in vec2 texCoord;

out vec3 ourColor;
out vec2 TexCoord;

void main()
{
    gl_Position = vec4(position, 1.0);
    ourColor = color;
    TexCoord = vec2( texCoord.x , 1.0 - texCoord.y );
}
</code></pre></li>
<li><p>Code of fragment shader:</p>

<pre><code>#version 330 core
in vec3 ourColor;
in vec2 TexCoord;

out vec4 color;

uniform sampler2D ourTexture1;

void main()
{
    color = texture(ourTexture1,TexCoord ) * vec4(ourColor,1.0);
}
</code></pre></li>
</ul>

<p>----------------------------------Following is my original question-----------------------------------------------</p>

<p>I met a problem with OpenGL programming, the console output is like this:</p>

<p><a href="https://i.stack.imgur.com/NfO98.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NfO98.png" alt="enter image description here"></a></p>

<p>The log is empty.</p>

<p>I've checked my code for several times and I really didn't know what the cause could be.</p>

<p>So can anyone tell me what may the cause be ?</p>

<p>Following is my shader code:</p>

<pre class="lang-cpp prettyprint-override"><code>#include &lt;string&gt;
#include &lt;fstream&gt;
#include &lt;sstream&gt;
#include &lt;iostream&gt;

#include &lt;GL/glew.h&gt;

class Shader
{
public:
GLuint Program;

// Constructor generates the shader on the fly
Shader( const GLchar *vertexPath, const GLchar *fragmentPath )
{
    // 1. Retrieve the vertex/fragment source code from filePath
    std::string vertexCode;
    std::string fragmentCode;
    std::ifstream vShaderFile;
    std::ifstream fShaderFile;
    // ensures ifstream objects can throw exceptions:
    vShaderFile.exceptions ( std::ifstream::badbit );
    fShaderFile.exceptions ( std::ifstream::badbit );
    try
    {
        // Open files
        vShaderFile.open( vertexPath );
        fShaderFile.open( fragmentPath );
        std::stringstream vShaderStream, fShaderStream;
        // Read file's buffer contents into streams
        vShaderStream &lt;&lt; vShaderFile.rdbuf( );
        fShaderStream &lt;&lt; fShaderFile.rdbuf( );
        // close file handlers
        vShaderFile.close( );
        fShaderFile.close( );
        // Convert stream into string
        vertexCode = vShaderStream.str( );
        fragmentCode = fShaderStream.str( );
    }
    catch ( std::ifstream::failure e )
    {
        std::cout &lt;&lt; "ERROR::SHADER::FILE_NOT_SUCCESFULLY_READ" &lt;&lt; std::endl;
    }
    const GLchar *vShaderCode = vertexCode.c_str( );
    const GLchar *fShaderCode = fragmentCode.c_str( );
    // 2. Compile shaders
    GLuint vertex, fragment;
    GLint success;
    GLchar infoLog[512];

    // Vertex Shader
    vertex = glCreateShader( GL_VERTEX_SHADER );
    glShaderSource( vertex, 1, &amp;vShaderCode, NULL );
    glCompileShader( vertex );
    // Print compile errors if any
    glGetShaderiv( vertex, GL_COMPILE_STATUS, &amp;success );
    std::cout &lt;&lt;"Vertex::" &lt;&lt; success &lt;&lt; std::endl;
    if ( !success )
    {
        glGetShaderInfoLog( vertex, 512, NULL, infoLog );
        std::cout &lt;&lt; "ERROR::SHADER::VERTEX::COMPILATION_FAILED\n" &lt;&lt; infoLog &lt;&lt; std::endl;
    }

    // Fragment Shader
    fragment = glCreateShader( GL_FRAGMENT_SHADER );
    glShaderSource( fragment, 1, &amp;fShaderCode, NULL );
    glCompileShader( fragment );
    // Print compile errors if any
    glGetShaderiv( fragment, GL_COMPILE_STATUS, &amp;success );
    std::cout &lt;&lt;"Fragment::" &lt;&lt; success &lt;&lt; std::endl;
    if ( !success )
    {
        glGetShaderInfoLog( fragment, 512, NULL, infoLog );
        std::cout &lt;&lt; "ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n" &lt;&lt; infoLog &lt;&lt; std::endl;
    }

    // Shader Program
    this-&gt;Program = glCreateProgram( );
    glAttachShader( this-&gt;Program, vertex );
    glAttachShader( this-&gt;Program, fragment );
    glLinkProgram( this-&gt;Program );
    // Print linking errors if any
    glGetProgramiv( this-&gt;Program, GL_LINK_STATUS, &amp;success );
    std::cout &lt;&lt;"linking::" &lt;&lt; success &lt;&lt; std::endl;

    if (!success)
    {
        glGetProgramInfoLog( this-&gt;Program, 512, NULL, infoLog );
        std::cout &lt;&lt; "ERROR::SHADER::PROGRAM::LINKING_FAILED\n" &lt;&lt; infoLog &lt;&lt; std::endl;
    }
    // Delete the shaders as they're linked into our program now and no longer necessery
    glDeleteShader( vertex );
    glDeleteShader( fragment );

}
// Uses the current shader
void Use( )
{
    glUseProgram( this-&gt;Program );
}

};
</code></pre>