Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7543827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:31:43+00:00 2026-05-30T08:31:43+00:00

I am programming in Netbeans, using MSYS, Qt, mingw and openGL and want to

  • 0

I am programming in Netbeans, using MSYS, Qt, mingw and openGL and want to know how to solve linker problems.

myWindow.h

#ifndef _MYWINDOW_H
#define _MYWINDOW_H

#include <QtOpenGL/QGLWidget>

class myWindow : public QGLWidget{
public:
    myWindow(QGLWidget* parent = 0);
private:
    void initializeGL();
    void paintGL();
    void resizeGL(int w, int  h);
    void drawCircle(int tr_x, int tr_y, float size);
};

#endif  /* _MYWINDOW_H */

myWindow.cpp

#include "myWindow.h"
#include <QtGui/QtGui>
#include <GL/glu.h>
#include <GL/gl.h>

myWindow::myWindow(QGLWidget* parent):QGLWidget(parent){
    setWindowTitle("lab1");
}

GLfloat circle[20][2] = {
{1, 0}, {0.951057, 0.309017}, {0.809017, 0.587785}, {0.587786, 0.809017},
{0.309018, 0.951056}, {0, 1}, {-0.309016, 0.951057}, {-0.587784, 0.809018},
{-0.809016, 0.587787}, {-0.951056, 0.309019},{-1, 0}, {-0.951057, -0.309014},
{-0.809019, -0.587783}, {-0.587788, -0.809015}, {-0.30902, -0.951055}, {0, -1},
{0.309013, -0.951058}, {0.587782, -0.80902}, {0.809014, -0.587789}, {0.951055, -0.309021}};

void myWindow::initializeGL(){
   qglClearColor(Qt::gray); 
   glEnable(GL_DEPTH_TEST);
   glShadeModel(GL_FLAT);
   glEnable(GL_CULL_FACE);
}

void myWindow::paintGL(){
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
   //glScalef(2, 2, 1);

   qglColor(Qt::white);

   renderText(-50, 150 , 0, QString::fromUtf8("This is a snowman!!!"), QFont());

   qglColor(Qt::black);
   drawCircle(10, 75, 3); //eye1
   drawCircle(-10, 75, 3); // eye2

   glLineWidth(3.0f);
   qglColor(Qt::red);
   glBegin(GL_LINES);
      glVertex2f(-10, 60);
      glVertex2f(0, 55);
      glVertex2f(0, 55);
      glVertex2f(10, 60);
   glEnd();

   glLineWidth(5.0f);
   qglColor(Qt::black);
   glBegin(GL_LINES);
      glVertex2f(-70, 10);
      glVertex2f(-38, 5);

      glVertex2f(38, 5);
      glVertex2f(70, 10);
   glEnd();

   qglColor(Qt::green);
   glBegin(GL_POLYGON);
      glVertex2f(-15, 120);
      glVertex2f(-20, 90);
      glVertex2f(20, 90);
      glVertex2f(15, 120);
   glEnd();

   QColor white(255, 255, 255, 255);
   qglColor(white);
   drawCircle(0, 65, 30);
   drawCircle(0, 0, 40);
   drawCircle(0, -85, 50);

   glFlush();
}

void myWindow::resizeGL(int w, int h){
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();

   gluOrtho2D(-w/2, w/2, -h/2, h/2);
   // Update OpenGL viewport and internal variables
   glViewport(0,0,w,h);
}

void myWindow::drawCircle(int tr_x, int tr_y, float size){
    int i;

    glBegin(GL_POLYGON);
    for(i = 0; i < 20; i++)
            glVertex2f(circle[i][0]*size+tr_x, circle[i][1]*size+tr_y);
    glEnd();
}

main.cpp

#include <QtGui/QApplication>
#include "myWindow.h"

int main(int argc, char *argv[]) {
    // initialize resources, if needed
    // Q_INIT_RESOURCE(resfile);

    QApplication app(argc, argv);

    myWindow win;
    win.show();

    // create and show your widgets here

    return app.exec();
}

NetBeans output:

/usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/Users/Galym/Documents/NetBeansProjects/qt'
/C/Qt/4.8.0/bin/qmake.exe VPATH=. -o qttmp-Debug.mk nbproject/qt-Debug.pro
mv -f qttmp-Debug.mk nbproject/qt-Debug.mk
/usr/bin/make -f nbproject/qt-Debug.mk dist/Debug/MinGW-Windows/qt.exe
make[2]: Entering directory `/c/Users/Galym/Documents/NetBeansProjects/qt'
g++.exe -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I'c:/Qt/4.8.0/include/QtCore' -I'c:/Qt/4.8.0/include/QtGui' -I'c:/Qt/4.8.0/include' -I'c:/Qt/4.8.0/include/ActiveQt' -I'.' -I'nbproject' -I'.' -I'c:/Qt/4.8.0/mkspecs/default' -o build/Debug/MinGW-Windows/myWindow.o myWindow.cpp
g++.exe -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I'c:/Qt/4.8.0/include/QtCore' -I'c:/Qt/4.8.0/include/QtGui' -I'c:/Qt/4.8.0/include' -I'c:/Qt/4.8.0/include/ActiveQt' -I'.' -I'nbproject' -I'.' -I'c:/Qt/4.8.0/mkspecs/default' -o build/Debug/MinGW-Windows/main.o main.cpp
windres -i qt_resource.rc -o build/Debug/MinGW-Windows/qt_resource_res.o --include-dir=. -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN
g++ -mthreads -Wl,-subsystem,windows -o dist/Debug/MinGW-Windows/qt.exe build/Debug/MinGW-Windows/myWindow.o build/Debug/MinGW-Windows/main.o  -L'c:/Qt/4.8.0/lib' -lmingw32 -lqtmaind build/Debug/MinGW-Windows/qt_resource_res.o -lglu32 -lopengl32 -lgdi32 -luser32 -lQtGuid4 -lQtCored4 
build/Debug/MinGW-Windows/myWindow.o: In function `myWindow':
C:\Users\Galym\Documents\NetBeansProjects\qt/myWindow.cpp:13: undefined reference to `_imp___ZN9QGLWidgetC2EP7QWidgetPKS_6QFlagsIN2Qt10WindowTypeEE'
C:\Users\Galym\Documents\NetBeansProjects\qt/myWindow.cpp:15: undefined reference to `_imp___ZN9QGLWidgetD2Ev'
C:\Users\Galym\Documents\NetBeansProjects\qt/myWindow.cpp:13: undefined reference to `_imp___ZN9QGLWidgetC2EP7QWidgetPKS_6QFlagsIN2Qt10WindowTypeEE'
C:\Users\Galym\Documents\NetBeansProjects\qt/myWindow.cpp:15: undefined reference to `_imp___ZN9QGLWidgetD2Ev'
build/Debug/MinGW-Windows/myWindow.o:C:\Users\Galym\Documents\NetBeansProjects\qt/myWindow.cpp:25: undefined reference to `_imp___ZNK9QGLWidget13qglClearColorERK6QColor'
build/Debug/MinGW-Windows/myWindow.o:C:\Users\Galym\Documents\NetBeansProjects\qt/myWindow.cpp:38: undefined reference to `_imp___ZNK9QGLWidget8qglColorERK6QColor'
build/Debug/MinGW-Windows/myWindow.o:C:\Users\Galym\Documents\NetBeansProjects\qt/myWindow.cpp:40: undefined reference to `_imp___ZN9QGLWidget10renderTextEdddRK7QStringRK5QFonti'
build/Debug/MinGW-Windows/myWindow.o:C:\Users\Galym\Documents\NetBeansProjects\qt/myWindow.cpp:42: undefined reference to `_imp___ZNK9QGLWidget8qglColorERK6QColor'
build/Debug/MinGW-Windows/myWindow.o:C:\Users\Galym\Documents\NetBeansProjects\qt/myWindow.cpp:47: undefined reference to `_imp___ZNK9QGLWidget8qglColorERK6QColor'
build/Debug/MinGW-Windows/myWindow.o:C:\Users\Galym\Documents\NetBeansProjects\qt/myWindow.cpp:56: undefined reference to `_imp___ZNK9QGLWidget8qglColorERK6QColor'
build/Debug/MinGW-Windows/myWindow.o:C:\Users\Galym\Documents\NetBeansProjects\qt/myWindow.cpp:65: undefined reference to `_imp___ZNK9QGLWidget8qglColorERK6QColor'
build/Debug/MinGW-Windows/myWindow.o:C:\Users\Galym\Documents\NetBeansProjects\qt/myWindow.cpp:74: undefined reference to `_imp___ZNK9QGLWidget8qglColorERK6QColor'
build/Debug/MinGW-Windows/myWindow.o:myWindow.cpp:(.rdata$_ZTV8myWindow[vtable for myWindow]+0x8): undefined reference to `QGLWidget::metaObject() const'
build/Debug/MinGW-Windows/myWindow.o:myWindow.cpp:(.rdata$_ZTV8myWindow[vtable for myWindow]+0xc): undefined reference to `QGLWidget::qt_metacast(char const*)'
build/Debug/MinGW-Windows/myWindow.o:myWindow.cpp:(.rdata$_ZTV8myWindow[vtable for myWindow]+0x10): undefined reference to `QGLWidget::qt_metacall(QMetaObject::Call, int, void**)'
build/Debug/MinGW-Windows/myWindow.o:myWindow.cpp:(.rdata$_ZTV8myWindow[vtable for myWindow]+0x1c): undefined reference to `QGLWidget::event(QEvent*)'
build/Debug/MinGW-Windows/myWindow.o:myWindow.cpp:(.rdata$_ZTV8myWindow[vtable for myWindow]+0x54): undefined reference to `QGLWidget::paintEngine() const'
build/Debug/MinGW-Windows/myWindow.o:myWindow.cpp:(.rdata$_ZTV8myWindow[vtable for myWindow]+0x84): undefined reference to `QGLWidget::paintEvent(QPaintEvent*)'
build/Debug/MinGW-Windows/myWindow.o:myWindow.cpp:(.rdata$_ZTV8myWindow[vtable for myWindow]+0x8c): undefined reference to `QGLWidget::resizeEvent(QResizeEvent*)'
build/Debug/MinGW-Windows/myWindow.o:myWindow.cpp:(.rdata$_ZTV8myWindow[vtable for myWindow]+0xe8): undefined reference to `QGLWidget::updateGL()'
build/Debug/MinGW-Windows/myWindow.o:myWindow.cpp:(.rdata$_ZTV8myWindow[vtable for myWindow]+0xec): undefined reference to `QGLWidget::updateOverlayGL()'
build/Debug/MinGW-Windows/myWindow.o:myWindow.cpp:(.rdata$_ZTV8myWindow[vtable for myWindow]+0xfc): undefined reference to `QGLWidget::initializeOverlayGL()'
build/Debug/MinGW-Windows/myWindow.o:myWindow.cpp:(.rdata$_ZTV8myWindow[vtable for myWindow]+0x100): undefined reference to `QGLWidget::resizeOverlayGL(int, int)'
build/Debug/MinGW-Windows/myWindow.o:myWindow.cpp:(.rdata$_ZTV8myWindow[vtable for myWindow]+0x104): undefined reference to `QGLWidget::paintOverlayGL()'
build/Debug/MinGW-Windows/myWindow.o:myWindow.cpp:(.rdata$_ZTV8myWindow[vtable for myWindow]+0x108): undefined reference to `QGLWidget::glInit()'
build/Debug/MinGW-Windows/myWindow.o:myWindow.cpp:(.rdata$_ZTV8myWindow[vtable for myWindow]+0x10c): undefined reference to `QGLWidget::glDraw()'
build/Debug/MinGW-Windows/myWindow.o:myWindow.cpp:(.rdata$_ZTV8myWindow[vtable for myWindow]+0x124): undefined reference to `non-virtual thunk to QGLWidget::paintEngine() const'
build/Debug/MinGW-Windows/myWindow.o: In function `~myWindow':
C:\Users\Galym\Documents\NetBeansProjects\qt/myWindow.h:13: undefined reference to `_imp___ZN9QGLWidgetD2Ev'
C:\Users\Galym\Documents\NetBeansProjects\qt/myWindow.h:13: undefined reference to `_imp___ZN9QGLWidgetD2Ev'
collect2: выполнение ld завершилось с кодом возврата 1
make[2]: *** [dist/Debug/MinGW-Windows/qt.exe] Error 1
make[2]: Leaving directory `/c/Users/Galym/Documents/NetBeansProjects/qt'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/c/Users/Galym/Documents/NetBeansProjects/qt'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 7s)

Environment variable PATH = C:\mingw\bin;C:\Qt\4.8.0\bin;

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T08:31:44+00:00Added an answer on May 30, 2026 at 8:31 am

    It would appear that you’re not including the QtOpenGL module in your compilation (or more specifically, linking) process.

    If you’re using .pro files for your project, you would need to add QT += opengl to it, to tell qmake that you’re using QtOpenGL. Other build systems might need you to do different things.

    When using NetBeans to manage the configuration, if you go into the Project properties, under Build -> Qt, there should be checkboxes for the various Qt modules, including QtOpenGL. Here you can enable/disable the linking to any of the Qt modules.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started with Gui Programming in netbeans (Using the template Java Desktop
I'm programming a desktop application in Java using NetBeans . My question is this:
I am using netbeans. I installed cygwin and use it for c++ programming in
I'm programming with Java in Linux using Netbeans 7 and as my program (sometimes)
Im using NetBeans 7.0.1 on a Mac, Code completion for Java programming is extremely
hi i am using netbeans 7 IDE for java programming , and i am
I downloaded the Netbeans plugin for programming with Ada. However, I don't know, how
For starters, this question is not so much about programming in the NetBeans IDE
I have just explore javaFX. I am now programming modul based application by netBeans
Okay, this is a bit messy: I'm using Netbeans, and I have a main

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.