Warning: no shaders attached to current program

So I have this function:


GLuint link(char* vertexFile, char* fragmentFile) {
    GLuint vertexShader;
    GLuint fragmentShader;
    GLint Result = GL_FALSE;
    int infoLogLength;
    
    string vF = getFile(vertexFile);
    string fF = getFile(fragmentFile);
    char* vertexSource = new char[vF.length()+1];
    char* fragmentSource = new char[fF.length()+1];
    strcpy(vertexSource, vF.c_str());
    strcpy(fragmentSource, fF.c_str());
    const char* fSource = fragmentSource;
    const char* vSource = vertexSource;
    glShaderSource(vertexShader, 1, &vSource, NULL);
    glShaderSource(fragmentShader, 1, &fSource, NULL);
    glCompileShader(vertexShader);
    glCompileShader(fragmentShader);
    
    glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &Result);
    glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &infoLogLength);
    char* VertexShaderErrorMessage = new char[infoLogLength+1];
    glGetShaderInfoLog(vertexShader, infoLogLength, NULL, &VertexShaderErrorMessage[0]);
    if(infoLogLength > 1) {
        fprintf(stdout, "%s
", &VertexShaderErrorMessage[0]);
        exit(EXIT_FAILURE);
    }
    
    glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &Result);
    glGetShaderiv(fragmentShader, GL_INFO_LOG_LENGTH, &infoLogLength);
    char* FragmentShaderErrorMessage = new char[infoLogLength+1];
    glGetShaderInfoLog(fragmentShader, infoLogLength, NULL, &FragmentShaderErrorMessage[0]);
    if(infoLogLength > 1) {
        fprintf(stdout, "%s
", &FragmentShaderErrorMessage[0]);
        exit(EXIT_FAILURE);
    }
    
    GLuint program = glCreateProgram();
    GLsizei* count;
    GLuint shaders;
    glAttachShader(program, vertexShader);
    glAttachShader(program, fragmentShader);
    glGetAttachedShaders(program, 999, count, &shaders);
    fprintf(stdout, "%d
", count);
    
    glLinkProgram(program);
    
    glGetProgramiv(program, GL_LINK_STATUS, &Result);
    glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength);
    char* ProgramErrorMessage = new char[max(infoLogLength, int(1))];
    glGetProgramInfoLog(program, infoLogLength, NULL, &ProgramErrorMessage[0]);
    if(infoLogLength > 1) {
        fprintf(stdout, "%s
", &ProgramErrorMessage[0]);
        exit(EXIT_FAILURE);
    }
    glDeleteShader(vertexShader);
    glDeleteShader(fragmentShader);
    
    return program;
    
}

That should be loading shaders into memory and linking them into program. The program is then activated (glUseProgram) on the main loop. As you can see, it contains all necessary basic error checks (partially copied from a tutorial). So when I run the program:


0
Warning: No shaders attached to current program 
 

RUN FAILED (exit value 1, total time: 435ms)

So the shaders don’t attach. They have been properly compiled without errors but even when I call glAttachShader they don’t attach. What’s the problem?

Oh, I forgot to actually create shaders. My bad :smiley: