Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. [SOLVED] How to use glut in my shared library
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] How to use glut in my shared library

Scheduled Pinned Locked Moved Installation and Deployment
6 Posts 4 Posters 6.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gamowaxaky
    wrote on 13 Sept 2012, 17:24 last edited by
    #1

    Hi everyone, I got a problem with using glut in my shared library. Please help me!
    I'm developing an application that draws 3D solid in a QWidget, I use glut library to initial, draw and so on... And the app works with no problem, but after a month, I realize bulding entire app is too slow, it take about 15 minutes for 1 build, so I decided to break my app into separate libraries to reduce the building time.
    It's ok with libraries doesn't include glut, but with glut included in my library, it can't compile, with
    @
    error: undefined reference to glBegin@4' error: undefined reference to glVertex3f@12'
    error: undefined reference to `glEnd@0'
    @
    Here is my library project:
    util.pro file:

    @
    LIBS += -L./lib -lglut32 #glut.lib, glut32.lib, libglut32.a here
    INCLUDEPATH += ./include #glut.h file here

    TARGET = util
    TEMPLATE = lib

    SOURCES += draw.cpp
    HEADERS += draw.h
    @
    Here is draw.h file:
    @
    void drawLine(float x1, float y1, float z1, float x2, float y2, float z2);
    @
    And draw.cpp file:
    @
    #include <glut.h>
    #include "draw.h"
    void drawLine(float x1, float y1, float z1, float x2, float y2, float z2){
    glBegin(GL_LINES);
    glVertex3f(x1,y1,z1);
    glVertex3f(x2,y2,z2);
    glEnd();
    }
    @
    I also try to use static library but it isn't work either.
    So how to use glut with static or shared library? Is it posible with qt?

    Any suggest will be appreciated!

    [Edit: Added @ tags for code formatting -- mlong]

    1 Reply Last reply
    0
    • R Offline
      R Offline
      rcari
      wrote on 18 Sept 2012, 12:12 last edited by
      #2

      The missing symbols do not come from GLUT but from OpenGL itself. You should add the OpenGL library as well in your LIBS.

      1 Reply Last reply
      0
      • V Offline
        V Offline
        Valiance
        wrote on 18 Sept 2012, 21:34 last edited by
        #3

        Which may be as simple as doing QT += opengl in your subprojects by the way.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          gamowaxaky
          wrote on 19 Sept 2012, 18:46 last edited by
          #4

          Thanks rcari & Don Harris so much!
          Finally, I can use glut in my library with your help.

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            QCZach
            wrote on 3 Feb 2015, 12:29 last edited by
            #5

            Would this work with QT 5 as well

            1 Reply Last reply
            0
            • Q Offline
              Q Offline
              QCZach
              wrote on 3 Feb 2015, 12:29 last edited by
              #6

              Would this work with QT 5 as well

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved