簡體   English   中英

Qt Creator中對glu的未定義引用

[英]Undefined Reference to glu in Qt Creator

編譯時,與glu相關的命令(例如gluPerspective和gluLookAt)出現錯誤。 我包含在* .pro文件中:

QT += core gui opengl widgets declarative 
LIBS     += -lOpengl32
TARGET   = test
TEMPLATE = app
TEMPLATE = lib

SOURCES += main.cpp\
           mainwindow.cpp \
           glwidget.cpp 
HEADERS  += mainwindow.h \
            glwidget.h

FORMS    += mainwindow.ui

DISTFILES += \
    freeglut.dll \
    glew32.dll

glwidget.h中:

#ifndef GLWIDGET_H
#define GLWIDGET_H
#include <QtOpenGL/QGLWidget>
#include <GL/GLU.h>
#include <QTimer>

class GLWidget : public QGLWidget {
    Q_OBJECT
public:
    //! CONSTRUCTOR
    GLWidget(QWidget *parent = 0);
    //! DESTRUCTOR
    ~GLWidget();

protected:
    /// OPENGL
    void initializeGL();
    void paintGL();        

};
#endif // GLWIDGET_H

glwidget.cpp:

 void GLWidget::paintGL() {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        gluPerspective( 60.0, 1.0, 0.5, 10.0 );
        gluLookAt( 0.0, -1.8, 5.0, 0.0, -2.7, 0.0, 0.0, 1.0, 0.0 );
    } 

當獲取gluPerspectivegluLookAt時,出現錯誤:未定義對'gluPerspective @ 32'的引用和未定義對'gluLookAT @ 72'的引用。 您知道使用glu庫的配置中缺少的內容嗎?

我認為您可能需要添加:

LIBS += -lglut -lGLU

到您的.pro文件,因為gluPerspective來自GLUT模塊。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM