Error: compileProgram: failed to link program

Hello,

I get this error every time I run the program. Error: compileProgram: failed to link program
I researched about the error. It comes in ProgramGL.cpp and inside ProgramGL::compileProgram().


void ProgramGL::compileProgram()
{
    if (_vertexShaderModule == nullptr || _fragmentShaderModule == nullptr)
        return;
    
    auto vertShader = _vertexShaderModule->getShader();
    auto fragShader = _fragmentShaderModule->getShader();
    
    assert (vertShader != 0 && fragShader != 0);
    if (vertShader == 0 || fragShader == 0)
        return;
    
    _program = glCreateProgram();
    log("%d", _program); # Added after then giving error.

    if (_program == 23) #Added after then giving error.
        return; #Added after then giving error.

    if (!_program)
        return;
    
    glAttachShader(_program, vertShader);
    glAttachShader(_program, fragShader);
    
    glLinkProgram(_program);
    GLint status = 0;
    glGetProgramiv(_program, GL_LINK_STATUS, &status);
    if (GL_FALSE == status)
    {
        printf("cocos2d: ERROR: %s: failed to link program ", __FUNCTION__);
        glDeleteProgram(_program);
        _program = 0;
    }
}

I tried to find the error on this code. I added some lines for testing purposes only. When the _program is 23, it gives an error. I’m just wondering. What is this 23? :smiley:

Doesn’t that indicate an error in your shader code? It should have printed a bit more info to the console output regarding what the error may be in the shader.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.