I have downloaded a QT OpenGL tutorial from <http://releases.qt-project.org/learning/developerguides/qtopengltutorial/OpenGLTutorial.pdf> and am trying to run the simplest example they have in there, which simply draws a triangle on top of a black background.

I managed to compile the example, but when I run it, I only get a black window and the console reports the following:

> 
> Starting
>  /home/minas/Desktop/hello-opengl-build-Desktop\_Qt\_5\_0\_1\_GCC\_64bit-Debug/hello-opengl...
>  QGLShaderProgram::uniformLocation( mvpMatrix ): shader program is not
>  linked QGLShaderProgram::uniformLocation( color ): shader program is
>  not linked QGLShaderProgram::attributeLocation( vertex ): shader
>  program is not linked QGLShaderProgram::attributeLocation( vertex ):
>  shader program is not linked QGLShaderProgram::attributeLocation(
>  vertex ): shader program is not linked 
>  QGLShaderProgram::uniformLocation( mvpMatrix ): shader program is not
>  linked QGLShaderProgram::uniformLocation( color ): shader program is
>  not linked QGLShaderProgram::attributeLocation( vertex ): shader
>  program is not linked QGLShaderProgram::attributeLocation( vertex ):
>  shader program is not linked QGLShaderProgram::attributeLocation(
>  vertex ): shader program is not linked 
>  QGLShaderProgram::uniformLocation( mvpMatrix ): shader program is not
>  linked QGLShaderProgram::uniformLocation( color ): shader program is
>  not linked QGLShaderProgram::attributeLocation( vertex ): shader
>  program is not linked QGLShaderProgram::attributeLocation( vertex ):
>  shader program is not linked QGLShaderProgram::attributeLocation(
>  vertex ): shader program is not linked 
>  QGLShaderProgram::uniformLocation( mvpMatrix ): shader program is not
>  linked QGLShaderProgram::uniformLocation( color ): shader program is
>  not linked QGLShaderProgram::attributeLocation( vertex ): shader
>  program is not linked QGLShaderProgram::attributeLocation( vertex ):
>  shader program is not linked QGLShaderProgram::attributeLocation(
>  vertex ): shader program is not linked
> 
> 
> 

The .pro file looks like this (the "unix:!mac" part is my addition, so it finds the OpenGL .so files).

```
QT += core gui opengl

TARGET = hello-opengl

TEMPLATE = app

SOURCES += main.cpp\
           glwidget.cpp

HEADERS += glwidget.h

OTHER_FILES += fragmentShader.fsh\
               vertexShader.vsh

RESOURCES += resources.qrc

unix:!mac{
    QMAKE_LFLAGS += -Wl,--rpath=/usr/lib64/nvidia-current
    QMAKE_LFLAGS += -L/usr/lib64/nvidia-current
}

```

The output of "glxinfo | grep -i opengl" is

```
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce 9800 GT/PCIe/SSE2
OpenGL version string: 2.1.2 NVIDIA 304.64
OpenGL shading language version string: (null)
OpenGL extensions:

```

and the part of the code that does the actual rendering is

```
void GlWidget::paintGL()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    QMatrix4x4 mMatrix;
    QMatrix4x4 vMatrix;

    // shaderProgram initialized in initializeGL()    
    shaderProgram.bind();

    // "mvpMatrix", "color" and "vertex" do exist in the shaders

    shaderProgram.setUniformValue("mvpMatrix", pMatrix * vMatrix * mMatrix);

    shaderProgram.setUniformValue("color", QColor(Qt::white));

    shaderProgram.setAttributeArray("vertex", vertices.constData());
    shaderProgram.enableAttributeArray("vertex");

    glDrawArrays(GL_TRIANGLES, 0, vertices.size());

    shaderProgram.disableAttributeArray("vertex");

    shaderProgram.release();
}

```

Also, as a side-question, why does the output of "glxinfo | grep -i opengl" contain the line

> 
> OpenGL shading language version string: (null)
> 
> 
> 

(kinda seems relevant to me... is it?)

---

EDIT 1
------

The `shaderProgram` is declared in my subclass of `QGLWidget`, which I call `GLWidget` and initialized in `initializeGL` as such:

```
void GlWidget::initializeGL()
{
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);

    qglClearColor(QColor(Qt::black));

    shaderProgram.addShaderFromSourceFile(QGLShader::Vertex, ":/vertexShader.vsh");
    shaderProgram.addShaderFromSourceFile(QGLShader::Fragment, ":/fragmentShader.fsh");
    shaderProgram.link();

    vertices << QVector3D(1, 0, -2) << QVector3D(0, 1, -2) << QVector3D(-1, 0, -2);
}

```

---

EDIT 2
------

Here is my initializeGL() method:

```
void GlWidget::initializeGL()
{
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);

    qglClearColor(QColor(Qt::black));

    shaderProgram.addShaderFromSourceFile(QGLShader::Vertex, ":/vertexShader.vsh");
    shaderProgram.addShaderFromSourceFile(QGLShader::Fragment, ":/fragmentShader.fsh");
    shaderProgram.link();

    vertices << QVector3D(1, 0, -2) << QVector3D(0, 1, -2) << QVector3D(-1, 0, -2);
}

```

and putting

```
qDebug() << shaderProgram.log();
exit(0);

```

immediately after the call to link() above does not produce any output.