Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

openGL in Mingw5.3 in Qt.5.11 error: undefined reference to `_imp__glBegin@4'



  • hi
    I'm using Qt 5.11 and mingw5.3_32bit
    i wont using openGl object like QOpenGLWidget or QGL Widget
    i give error like :
    D:\web_for_up\mrzx-website\qt\MRZX_ir_2\myMenu\myMenu\myglwidget.cpp:14: error: undefined reference to `_imp__glClearColor@16'

    D:\web_for_up\mrzx-website\qt\MRZX_ir_2\myMenu\myMenu\myglwidget.cpp:28: error: undefined reference to `_imp__glBegin@4'
    ...
    how to fi this?

    #ifndef MYGLWIDGET_H
    #define MYGLWIDGET_H
    
    #include <QOpenGLWidget>
    
    class myGLWidget: public QOpenGLWidget
    {
        Q_OBJECT
    public:
        myGLWidget(QWidget *parent=0);
    protected:
        void initializeGL();
        void resizeGL(int w, int h);
        void paintGL();
    
    };
    
    #endif // MYGLWIDGET_H
    
    #include <QtWidgets>
    #include "myglwidget.h"
    #include <QtOpenGL>
    myGLWidget::myGLWidget(QWidget *parent):
        QOpenGLWidget(parent)
    {
    
    }
    
    void myGLWidget::initializeGL()
    {
         glClearColor(1.0f, 1.0f, 0.0f, 1.0f);
    
    }
    
    void myGLWidget::resizeGL(int w, int h)
    {
        glViewport(0, 0, w, h);
    }
    
    void myGLWidget::paintGL()
    {
       glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
               glColor3f(1,0,0);
                glBegin(GL_TRIANGLES);
                glVertex3f(-0.5, -0.5, 0);
                glVertex3f( 0.5, -0.5, 0);
                glVertex3f( 0.0, 0.5, 0);
                glEnd();
    }
    
    

Log in to reply